transform mode commit
authorJean-Luc Peurière <jlp@nerim.net>
Tue, 31 Jul 2007 17:45:26 +0000 (17:45 +0000)
committerJean-Luc Peurière <jlp@nerim.net>
Tue, 31 Jul 2007 17:45:26 +0000 (17:45 +0000)
you can now translate or rotate a selected object
in the third method. either in object or edit mode.

Note : the method is not ideal, as we create a full
transform loop for each component of the transform.
However it is this way handled in same way as other
means of input

source/blender/src/space.c
source/blender/src/transform.c
source/blender/src/view.c

index cc3109cb57ae10771d47d6518531ad245f2723ad..6250061f94cd570966304d935154a94140cfe486 100644 (file)
@@ -1573,7 +1573,9 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt)
                                } else if (G.vd->ndofmode == 1) {
                                        viewmoveNDOFfly(1);
                                } else {
-                                       ;
+                                       if (OBACT) {
+                                               ndof_transform();
+                                       }
                                }
                                        
                 break;
index 9e6c1b689379f86ee926b6afb90e2c0b53132086..d8bd30796f200c05b8aebff6e3cbe35d3cece1ca 100755 (executable)
@@ -3106,4 +3106,98 @@ void BIF_TransformSetUndo(char *str)
        Trans.undostr= str;
 }
 
+void ndof_do_transform(float *fval)
+{
+       char str[200];
+       float fvec[3] = {0.0,0.0,0.0};
+       char change = 0;
+       
+//     fprintf(stderr,"passing here %f %f %f \n",fval[3],fval[4],fval[5]);
+
+       
+       if (fval[3] != 0.0 ) {
+               fvec[0] = 1.0;
+               initTransform(TFM_ROTATION, CTX_NONE);
+               applyRotation(&Trans, fval[3], fvec);
+               recalcData(&Trans);
+               change =1;
+               fvec[0] = 0.0;
+               drawSnapping(&Trans);
+               /* free data */
+               postTrans(&Trans);
+               
+               /* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
+               special_aftertrans_update(&Trans);
+               
+       }
+       if (fval[4] != 0.0 ) {
+               fvec[1] = 1.0;
+               initTransform(TFM_ROTATION, CTX_NONE);
+               applyRotation(&Trans, fval[4], fvec);
+               recalcData(&Trans);
+               change =1;
+               fvec[1] = 0.0;
+               drawSnapping(&Trans);
+               /* free data */
+               postTrans(&Trans);
+               
+               /* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
+               special_aftertrans_update(&Trans);
+               
+       }
+       if (fval[5] != 0.0 ) {
+               fvec[2] = 1.0;
+               initTransform(TFM_ROTATION, CTX_NONE);
+               applyRotation(&Trans, fval[5], fvec);
+               recalcData(&Trans);
+               change =1;
+               fvec[2] = 0.0;
+               drawSnapping(&Trans);
+               /* free data */
+               postTrans(&Trans);
+               
+               /* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
+               special_aftertrans_update(&Trans);
+               
+       }
+       
+       
+       if ((fval[0] != 0.0 )|( fval[1] != 0.0 )| (fval[2] != 0.0)) {
+               initTransform(TFM_TRANSLATION, CTX_NONE);
+               Trans.vec[0] = fval[0];
+               Trans.vec[1] = fval[1];     
+               Trans.vec[2] = fval[2]; 
+               
+               applyTranslation(&Trans, Trans.vec);
+               
+               /* evil hack - redo translation if cliiping needeed */
+               if (Trans.flag & T_CLIP_UV && clipUVTransform(&Trans, Trans.vec, 0))
+                       applyTranslation(&Trans, Trans.vec);
+               
+               recalcData(&Trans);
+               change =1;
+               drawSnapping(&Trans);
+               /* free data */
+               postTrans(&Trans);
+               
+               /* aftertrans does insert ipos and action channels, and clears base flags, doesnt read transdata */
+               special_aftertrans_update(&Trans);
+               
+       }
+       
+
+       
+       if (change) {   
+               ;
+       }
+               
+               /* send events out for redraws */
+               viewRedrawPost(&Trans);
+               
+               if(Trans.undostr) BIF_undo_push(Trans.undostr);
+               else BIF_undo_push(transform_to_undostr(&Trans));
+               
+               Trans.undostr= NULL;
+               
 
+}
\ No newline at end of file
index 029222963b6facdcfc25a0361f748d9184f9b8cf..c2aaee81ff07537d2aa4e5c6fbc76ea0915cdadf 100644 (file)
@@ -2214,3 +2214,22 @@ void smooth_view_to_camera(View3D *v3d)
                v3d->persp=2;
        }
 }
+
+void ndof_transform(void)
+{
+    float fval[7];
+
+       getndof(fval);
+
+       if (G.vd->ndoffilter)
+               filterNDOFvalues(fval);
+       
+       fval[0] =  fval[0] * (1.0f/1024.0f);
+       fval[1] = -fval[1] * (1.0f/1024.0f);    // axis inversion
+       fval[2] = -fval[2] * (1.0f/1024.0f);    // axis inversion
+       fval[3] =  fval[3] * (1.0f/8024.0f);
+       fval[4] =  fval[4] * (1.0f/8024.0f);
+       fval[5] =  fval[5] * (1.0f/8024.0f);
+       
+       ndof_do_transform(fval);
+}