Revision: 6771
          http://playerstage.svn.sourceforge.net/playerstage/?rev=6771&view=rev
Author:   jeremy_asher
Date:     2008-07-04 17:43:45 -0700 (Fri, 04 Jul 2008)

Log Message:
-----------
Fixed speech bubble positioning in perspective mode, scaling still off

Modified Paths:
--------------
    code/stage/trunk/libstage/model.cc

Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc  2008-07-05 00:38:55 UTC (rev 6770)
+++ code/stage/trunk/libstage/model.cc  2008-07-05 00:43:45 UTC (rev 6771)
@@ -912,54 +912,65 @@
 
 void StgModel::DrawStatus( StgCanvas* canvas ) 
 {
-  // draw speech bubble
-  if( say_string )
-    {
-      float stheta = -dtor( canvas->current_camera->pitch() );
-      float sphi = dtor( canvas->current_camera->yaw() );
-      float scale = canvas->camera.getScale();
-               if( canvas->perspectiveCam == true ) {
-                       sphi = atan2(
-                                                ( pose.x - 
canvas->current_camera->x() )
-                                                ,
-                                                ( pose.y - 
canvas->current_camera->y() )
-                                                );
-                       stheta = -stheta;
-               }
+       if( say_string )          
+       {
+               float yaw, pitch, scale;
+
                
-      glPushMatrix();
+               float x,y,z;
+               x = canvas->current_camera->x() - pose.x;
+               y = canvas->current_camera->y() - pose.y;
+               z = canvas->current_camera->z() - pose.z - 0.5;
+               float dist = sqrt( exp2f(x) + exp2f(y) + exp2f(z) );
+               printf("x: %f, y: %f, z: %f, dist: %f, scale: %f\n", x, y, z, 
dist, scale);
                
-      // move above the robot
-      glTranslatef( 0, 0, 0.5 );               
+               if ( canvas->perspectiveCam ) {
+                       pitch = -canvas->current_camera->pitch();
+                       yaw = -canvas->current_camera->yaw();                   
+                       scale = 500/dist;
+               }
+               else {
+                       pitch = canvas->current_camera->pitch();
+                       yaw = canvas->current_camera->yaw();                    
+                       scale = canvas->camera.getScale();
+               }
+       
+               float robotAngle = -rtod(pose.a);
                
-      // rotate to face screen
-      glRotatef( -rtod(global_pose.a + sphi), 0,0,1 );
-      glRotatef( rtod(stheta), 1,0,0 );
+
                
-      const float m = 4 / scale; // margin
-      float w = gl_width( this->say_string ) / scale; // scaled text width
-      float h = gl_height() / scale; // scaled text height
+               glPushMatrix();
+
+               // move above the robot
+               glTranslatef( 0, 0, 0.5 );              
+
+               // rotate to face screen
+               glRotatef( robotAngle - yaw, 0,0,1 );
+               glRotatef( -pitch, 1,0,0 );
+                               
+               const float m = 4 / scale; // margin
+               float w = gl_width( this->say_string ) / scale; // scaled text 
width
+               float h = gl_height() / scale; // scaled text height
+
+               // draw inside of bubble
+               PushColor( BUBBLE_FILL );
+               glPushAttrib( GL_POLYGON_BIT | GL_LINE_BIT );
+               glPolygonMode( GL_FRONT, GL_FILL );
+               glEnable( GL_POLYGON_OFFSET_FILL );
+               glPolygonOffset( 1.0, 1.0 );
+               gl_draw_octagon( w, h, m );
+               glDisable( GL_POLYGON_OFFSET_FILL );
+               PopColor();
+               // draw outline of bubble
+               PushColor( BUBBLE_BORDER );
+               glLineWidth( 1 );
+               glEnable( GL_LINE_SMOOTH );
+               glPolygonMode( GL_FRONT, GL_LINE );
+               gl_draw_octagon( w, h, m );
+               glPopAttrib();
+               PopColor();
                
                
-      // draw inside of bubble
-      PushColor( BUBBLE_FILL );
-      glPushAttrib( GL_POLYGON_BIT | GL_LINE_BIT );
-      glPolygonMode( GL_FRONT, GL_FILL );
-      glEnable( GL_POLYGON_OFFSET_FILL );
-      glPolygonOffset( 1.0, 1.0 );
-      gl_draw_octagon( w, h, m );
-      glDisable( GL_POLYGON_OFFSET_FILL );
-      PopColor();
-      // draw outline of bubble
-      PushColor( BUBBLE_BORDER );
-      glLineWidth( 1 );
-      glEnable( GL_LINE_SMOOTH );
-      glPolygonMode( GL_FRONT, GL_LINE );
-      gl_draw_octagon( w, h, m );
-      glPopAttrib();
-      PopColor();
-               
-               
       // draw text
       PushColor( BUBBLE_TEXT );
       glTranslatef( 0, 0, 0.1 ); // draw text forwards of bubble


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Playerstage-commit mailing list
Playerstage-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to