Revision: 6941
http://playerstage.svn.sourceforge.net/playerstage/?rev=6941&view=rev
Author: jeremy_asher
Date: 2008-08-01 19:48:20 +0000 (Fri, 01 Aug 2008)
Log Message:
-----------
stage: restored speech bubble octagons
Modified Paths:
--------------
code/stage/trunk/libstage/model.cc
Modified: code/stage/trunk/libstage/model.cc
===================================================================
--- code/stage/trunk/libstage/model.cc 2008-08-01 19:04:51 UTC (rev 6940)
+++ code/stage/trunk/libstage/model.cc 2008-08-01 19:48:20 UTC (rev 6941)
@@ -1020,9 +1020,6 @@
float robotAngle = -rtod(pose.a);
glPushMatrix();
- //TODO ask jeremy to fancy up the octagons
- //const float m = 4; // margin
-
float w = gl_width( this->say_string ); // scaled text width
float h = gl_height(); // scaled text height
@@ -1041,33 +1038,50 @@
GLboolean valid;
glGetBooleanv( GL_CURRENT_RASTER_POSITION_VALID, &valid );
if( valid == true ) {
+ GLdouble wx, wy, wz;
+ int viewport[4];
+ glGetIntegerv(GL_VIEWPORT, viewport);
- {
- GLdouble wx, wy, wz;
- int viewport[4];
- glGetIntegerv(GL_VIEWPORT, viewport);
-
- GLdouble modelview[16];
- glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
-
- GLdouble projection[16];
- glGetDoublev(GL_PROJECTION_MATRIX, projection);
-
- //get width and height in world coords
- gluUnProject( pos[0] + w, pos[1], pos[2],
modelview, projection, viewport, &wx, &wy, &wz );
- w = wx;
- gluUnProject( pos[0], pos[1] + h, pos[2],
modelview, projection, viewport, &wx, &wy, &wz );
- h = wy;
- }
+ GLdouble modelview[16];
+ glGetDoublev(GL_MODELVIEW_MATRIX, modelview);
- glColor3f( 1, 0.8, 1 );
- gl_draw_octagon( w, h, 0 );
+ GLdouble projection[16];
+ glGetDoublev(GL_PROJECTION_MATRIX, projection);
- glColor3f( 0, 0, 0 );
- //position text ontop of string (might be problematic
if too large in perspective mode)
- glTranslatef( 0, 0, 0.003 );
- gl_draw_string( 0, 0, 0.0, this->say_string );
+ //get width and height in world coords
+ gluUnProject( pos[0] + w, pos[1], pos[2], modelview,
projection, viewport, &wx, &wy, &wz );
+ w = wx;
+ gluUnProject( pos[0], pos[1] + h, pos[2], modelview,
projection, viewport, &wx, &wy, &wz );
+ h = wy;
+
+ // calculate speech bubble margin
+ const float m = h/10;
+
+ // 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();
+
+ PushColor( BUBBLE_TEXT );
+ // draw text inside the bubble
+ gl_draw_string( 2*m, 2*m, 0, this->say_string );
+ PopColor();
+
glPopMatrix();
}
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit