Revision: 7171 http://playerstage.svn.sourceforge.net/playerstage/?rev=7171&view=rev Author: rtv Date: 2008-11-26 19:44:48 +0000 (Wed, 26 Nov 2008)
Log Message: ----------- added quick waypoint property and vis Modified Paths: -------------- code/stage/trunk/examples/ctrl/fasr.cc code/stage/trunk/libstage/CMakeLists.txt code/stage/trunk/libstage/canvas.cc code/stage/trunk/libstage/model.cc code/stage/trunk/libstage/stage.hh Modified: code/stage/trunk/examples/ctrl/fasr.cc =================================================================== --- code/stage/trunk/examples/ctrl/fasr.cc 2008-11-25 22:47:00 UTC (rev 7170) +++ code/stage/trunk/examples/ctrl/fasr.cc 2008-11-26 19:44:48 UTC (rev 7171) @@ -77,6 +77,20 @@ robot->sink = mod->GetWorld()->GetModel( "sink" ); assert(robot->sink); + const uint32_t wp_count = 100; + Waypoint* wps = new Waypoint[wp_count]; + + for( int i=0; i<wp_count; i++ ) + { + wps[i].pose.x = i / 12.5; + wps[i].pose.y = 4.0*drand48() - 2.0; + wps[i].pose.z = 0; + wps[i].pose.a = 0; + wps[i].color = stg_color_pack( 1,0,1,0 ); + } + + robot->pos->SetWaypoints( wps, wp_count ); + return 0; //ok } Modified: code/stage/trunk/libstage/CMakeLists.txt =================================================================== --- code/stage/trunk/libstage/CMakeLists.txt 2008-11-25 22:47:00 UTC (rev 7170) +++ code/stage/trunk/libstage/CMakeLists.txt 2008-11-26 19:44:48 UTC (rev 7171) @@ -30,6 +30,7 @@ stage.hh texture_manager.cc typetable.cc + waypoint.cc world.cc worldfile.cc worldgui.cc Modified: code/stage/trunk/libstage/canvas.cc =================================================================== --- code/stage/trunk/libstage/canvas.cc 2008-11-25 22:47:00 UTC (rev 7170) +++ code/stage/trunk/libstage/canvas.cc 2008-11-26 19:44:48 UTC (rev 7171) @@ -760,7 +760,10 @@ if( showBBoxes ) DrawBoundingBoxes(); - + + // TODO - finish this properly + LISTMETHOD( models_sorted, StgModel*, DrawWaypoints ); + // MOTION BLUR if( showBlur ) { @@ -879,7 +882,7 @@ last_selection->DataVisualizeTree( current_camera ); } } - + if( showGrid ) LISTMETHOD( models_sorted, StgModel*, DrawGrid ); Modified: code/stage/trunk/libstage/model.cc =================================================================== --- code/stage/trunk/libstage/model.cc 2008-11-25 22:47:00 UTC (rev 7170) +++ code/stage/trunk/libstage/model.cc 2008-11-26 19:44:48 UTC (rev 7171) @@ -194,7 +194,9 @@ wf_entity(0), has_default_block( true ), map_caches_are_invalid( true ), - thread_safe( false ) + thread_safe( false ), + waypoints( NULL ), + waypoint_count( 0 ) { assert( modelsbyid ); assert( world ); @@ -1677,3 +1679,34 @@ } +/** Set the waypoint array pointer. Returns the old pointer, in case you need to free/delete[] it */ +Waypoint* StgModel::SetWaypoints( Waypoint* wps, uint32_t count ) +{ + Waypoint* replaced = waypoints; + + waypoints = wps; + waypoint_count = count; + + return replaced; +} + + +void StgModel::DrawWaypoints() +{ + if( waypoints && waypoint_count ) + { + //PushLocalCoords(); + + PushColor( color ); + glPointSize( 3 ); + + // puts( "drawing wps" ); + + for( unsigned int i=0; i < waypoint_count; i++ ) + waypoints[i].Draw(); + + //PopCoords(); + // restore a sensible drawing color + PopColor(); + } +} Modified: code/stage/trunk/libstage/stage.hh =================================================================== --- code/stage/trunk/libstage/stage.hh 2008-11-25 22:47:00 UTC (rev 7170) +++ code/stage/trunk/libstage/stage.hh 2008-11-26 19:44:48 UTC (rev 7171) @@ -348,7 +348,18 @@ size.y ); } }; + + class Waypoint + { + public: + Waypoint( stg_meters_t x, stg_meters_t y, stg_meters_t z, stg_radians_t a, stg_color_t color ) ; + Waypoint(); + void Draw(); + stg_pose_t pose; + stg_color_t color; + }; + /** bound a range of values, from min to max */ typedef struct { @@ -868,7 +879,7 @@ static GList* world_list; ///< all the worlds that exist static bool quit_all; ///< quit all worlds ASAP static unsigned int next_id; ///<initially zero, used to allocate unique sequential world ids - + stg_usec_t real_time_start; ///< the real time at which this world was created bool destroy; bool quit; ///< quit this world ASAP @@ -1054,6 +1065,7 @@ /** Return the number of times the world has been updated. */ long unsigned int GetUpdateCount() { return updates; } + // stg_point_t* LocalToGlobal( double scalex, double scaley, // stg_point_t pts[], @@ -1291,7 +1303,10 @@ GMutex* access_mutex; - + Waypoint* waypoints; + uint32_t waypoint_count; + void DrawWaypoints(); + public: void Lock() { @@ -1546,6 +1561,9 @@ bool IsDescendent( StgModel* testmod ); bool IsRelated( StgModel* mod2 ); + + /** Set the waypoint array pointer. Returns the old pointer, in case you need to free/delete[] it */ + Waypoint* SetWaypoints( Waypoint* wps, uint32_t count ); /** get the pose of a model in the global CS */ stg_pose_t GetGlobalPose(); 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 Playerstage-commit@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/playerstage-commit