Laser Sensing Display for UI interfaces in the real world

Dependencies:   mbed

Fork of skinGames_forktest by Alvaro Cassinelli

Revision:
47:199042980678
Parent:
44:2432c218f191
--- a/WrapperFunctions.cpp	Sun Mar 30 08:58:59 2014 +0000
+++ b/WrapperFunctions.cpp	Thu Apr 17 08:04:14 2014 +0000
@@ -168,10 +168,10 @@
 // I will implement both, because even the first option can be useful (to create more complex scenes by rotating already created objects for instance - but it will be trickier to understand though)
 
 // (1) applying a transformation on the 3d points (NOTE: we could also apply transformations on the projected points! this is however a work for the "viewport").
-// NOTE: I am not going to create new transform methods (rotation and translations), but instead use the lsr stack. So, I assume the user has set RT to what she wants. Then, we will
+// NOTE: I may later create specific transform methods (rotation and translations), but in general we can use the lsr stack. So, I assume the user has set RT to what she wants. Then, we will
 // just apply RT to the object or whole scene. This method can be used to RESIZE the object (in particular when it is centered).
 //(a) Objects:
-void trasformObject(int _id)   // use maps in the future!!!
+void transformObject(int _id)   // use maps in the future!!!
 {
     BaseObject* ptr_object=NULL;
     for (int i=0; i<scene.totalObjects(); i++) if ((scene.objectArray[i]->ID())==_id) ptr_object=scene.objectArray[i];
@@ -195,6 +195,49 @@
     // lsr.renderScene(&scene);
 }
 
+// Some elementary transformations (again, note that this if applied too much will make the object eventually deform - it would be much better to do the 
+// rotation/translation actions as part of a program IN the mbed, instead of sending commands:
+void translateObject(int _id, int xx, int yy, int zz) {
+    lsr.pushPoseMatrix();
+    lsr.setIdentityPose(); // we could use a wrapper, but I won't for the time being.
+    lsr.flipY(); // there is a pb here...
+    //lsr.flipX();
+    lsr.translate(xx,yy,zz);
+    transformObject(_id);
+    lsr.popPoseMatrix();
+}
+
+void rotateObjectX(int _id, float alpha) {
+    lsr.pushPoseMatrix();
+    lsr.setIdentityPose(); // we could use a wrapper, but I won't for the time being.
+    lsr.flipY();
+    //lsr.flipX();
+    lsr.rotateX(alpha);
+    transformObject(_id);
+    lsr.popPoseMatrix();
+    }
+    
+void rotateObjectY(int _id, float alpha){
+     lsr.pushPoseMatrix();
+    lsr.setIdentityPose(); // we could use a wrapper, but I won't for the time being.
+    lsr.flipY();
+    //lsr.flipX();
+    lsr.rotateY(alpha);
+    transformObject(_id);
+    lsr.popPoseMatrix();
+    }
+    
+void rotateObjectZ(int _id, float alpha) { lsr.pushPoseMatrix();
+    lsr.setIdentityPose(); // we could use a wrapper, but I won't for the time being.
+    lsr.flipY();
+    //lsr.flipX();
+    lsr.rotateZ(alpha);
+    transformObject(_id);
+    lsr.popPoseMatrix();
+    }
+ 
+// =======================================================================================================
+
 //(2) Apply current RT transformation and render but KEEPING the original values of the 3d points:
 //(a) Objects:
 void drawObject(int _id)   // use maps in the future!!!