"Set Camera to View3d": SHIFT-NUMPAD0 selects the camera like NUMPAD0, and
authorAlexander Ewering <blender@instinctive.de>
Sat, 27 Sep 2003 11:10:49 +0000 (11:10 +0000)
committerAlexander Ewering <blender@instinctive.de>
Sat, 27 Sep 2003 11:10:49 +0000 (11:10 +0000)
in addition aligns and positions it so that it exactly "sees" the former
View3d.

source/blender/src/toets.c
source/blender/src/view.c

index 6394959dd0c37d34a0dd66dff5b65d6af59810de..edc328dd6ee055ef980d15d7461d7fde90b84487 100644 (file)
@@ -391,8 +391,10 @@ void persptoetsen(unsigned short event)
                        if(G.vd->camera) {
                                G.vd->persp= 2;
                                G.vd->view= 0;
+                               if(G.qual & LR_SHIFTKEY) {
+                                       setcameratoview3d();
+                               }                               
                        }
-                       
                }
                else if(event==PAD9) {
                        countall();
index 30eb5acbb9b647642ce1e9cc24bcc241f6e26d8d..b1d0c367cec23708e74bd577602d7382d3948419 100644 (file)
@@ -711,6 +711,26 @@ void setviewmatrixview3d()
        }
 }
 
+void setcameratoview3d()
+{
+       Object *ob;
+       float dvec[3];
+
+       ob= G.vd->camera;
+       dvec[0]= G.vd->dist*G.vd->viewinv[2][0];
+       dvec[1]= G.vd->dist*G.vd->viewinv[2][1];
+       dvec[2]= G.vd->dist*G.vd->viewinv[2][2];                                        
+       VECCOPY(ob->loc, dvec);
+       VecSubf(ob->loc, ob->loc, G.vd->ofs);
+       G.vd->viewquat[0]= -G.vd->viewquat[0];
+       if (ob->transflag & OB_QUAT) {
+               QUATCOPY(ob->quat, G.vd->viewquat);
+       } else {
+               QuatToEul(G.vd->viewquat, ob->rot);
+       }
+       G.vd->viewquat[0]= -G.vd->viewquat[0];
+}
+
 /* IGLuint-> GLuint*/
 short selectprojektie(unsigned int *buffer, short x1, short y1, short x2, short y2)
 {