Update of /cvsroot//sserver/rcsoccersim/rcssserver3D/app/rcssmonitor3d/lite
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21677
Modified Files:
monitor.cpp monitor.h
Log Message:
- updated list of key bindings
- fast/realtime replay of logs can be toggled with 'f'
- added support for drawing of velocities in 2D and 3D (toggle with 'v')
- removed some obsolete debugging output
- added translucent background to 2D overview
Index: monitor.cpp
===================================================================
RCS file: /cvsroot//sserver/rcsoccersim/rcssserver3D/app/rcssmonitor3d/lite/monitor.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** monitor.cpp 24 Jan 2005 12:36:26 -0000 1.18
--- monitor.cpp 24 May 2005 11:31:16 -0000 1.19
***************
*** 71,75 ****
Monitor::Instance()->Idle();
}
-
// color constants
const GLfloat
--- 71,74 ----
***************
*** 100,103 ****
--- 99,105 ----
const GLfloat
Monitor::sDebugColorPink[4] = {1.0f, 0.0f, 1.0f, 0.5f};
+ //color for ground of overview field
+ const GLfloat
+ Monitor::sGroundColor2D[4] = {0.0f, 0.6f, 0.0f, 0.8f};
// radius of center circle
***************
*** 135,138 ****
--- 137,141 ----
mDrawOverview = true;
mDrawDebug = false;
+ mDrawVelocity = false;
mServer = DEFAULT_HOST;
mPort = DEFAULT_PORT;
***************
*** 308,311 ****
--- 311,315 ----
"1 | toggle display of debug information\n"
"2 | toggle display of two dimensional overview\n"
+ "v | toggle display of velocities\n"
"? | display keybindings\n"
"----------------------------------------------------\n"
***************
*** 328,331 ****
--- 332,337 ----
"LOGPLAYER\n"
"----------------------------------------------------\n"
+ "f | toggle fast/realtime replay\n"
+ "F | Realtime replay\n"
"m | toggle single step mode for logplayer\n"
"> | move one step forward\n"
***************
*** 506,510 ****
// resolution of a sphere
! int res = 8;
const float& fl = mGameState.GetFieldLength();
--- 512,516 ----
// resolution of a sphere
! int res = 6;
const float& fl = mGameState.GetFieldLength();
***************
*** 516,519 ****
--- 522,537 ----
// field rect
+
+ glEnable(GL_BLEND); // Turn Blending On
+
+ glColor4fv(sGroundColor2D);
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex3fv(Get2DPos(Vector3f(-fl/2,-fw/2,0)).GetData());
+ glVertex3fv(Get2DPos(Vector3f(fl/2,-fw/2,0)).GetData());
+ glVertex3fv(Get2DPos(Vector3f(-fl/2,fw/2,0)).GetData());
+ glVertex3fv(Get2DPos(Vector3f(fl/2,fw/2,0)).GetData());
+ glEnd();
+ glDisable(GL_BLEND); // Turn Blending Off
+
glColor4fv(sLineColor);
glBegin(GL_LINE_LOOP);
***************
*** 565,579 ****
glEnd();
! Vector3f pos;
float size;
- if (mGameState.GetBall(pos, size))
- {
- glColor4fv(sBallColor);
- mGLServer.DrawSphere(Get2DPos(pos), b_radius, res);
- }
int i = 0;
int unum;
TTeamIndex side;
while (mGameState.GetPlayer(i, pos, side, unum, size))
{
--- 583,596 ----
glEnd();
! Vector3f pos,oldpos;
float size;
int i = 0;
int unum;
TTeamIndex side;
+
+ //JAN
+ float timeDiff = mGameState.GetTime() - mOldGameState.GetTime();
+
while (mGameState.GetPlayer(i, pos, side, unum, size))
{
***************
*** 592,595 ****
--- 609,620 ----
mGLServer.DrawSphere(Get2DPos(pos), pl_radius, res);
+ if (mDrawVelocity && timeDiff != 0.0)
+ {
+
+ glColor3f(1.0f,1.0f,1.0f);
+ mOldGameState.GetPlayer(i, oldpos, side, unum, size);
+ mGLServer.DrawArbitraryLine(Get2DPos(pos), Get2DPos(pos + (pos-oldpos)/timeDiff));
+ }
+
if (mDrawUnums)
{
***************
*** 602,605 ****
--- 627,644 ----
++i;
}
+
+ if (mGameState.GetBall(pos, size))
+ {
+ glDisable(GL_DEPTH_TEST);
+ glColor4fv(sBallColor);
+ mGLServer.DrawSphere(Get2DPos(pos), b_radius, res);
+ if (mDrawVelocity && timeDiff != 0.0)
+ {
+ glColor3f(1.0f,1.0f,1.0f);
+ mOldGameState.GetBall(oldpos);
+ mGLServer.DrawArbitraryLine(Get2DPos(pos), Get2DPos(pos + (pos-oldpos)/timeDiff));
+ }
+ glEnable(GL_DEPTH_TEST);
+ }
}
***************
*** 686,692 ****
glColor4fv(sDebugColorPink);
! mGLServer.DrawArbitraryLine(Vector3f(0,0,0), Vector3f(10,0,0));
! mGLServer.DrawArbitraryLine(Vector3f(0,0,0), Vector3f(0,10,0));
! mGLServer.DrawArbitraryLine(Vector3f(0,0,0), Vector3f(0,0,10));
return;
}
--- 725,740 ----
glColor4fv(sDebugColorPink);
! // mGLServer.DrawArbitraryLine(Vector3f(0,0,0), Vector3f(10,0,0));
! // mGLServer.DrawArbitraryLine(Vector3f(0,0,0), Vector3f(0,10,0));
! // mGLServer.DrawArbitraryLine(Vector3f(0,0,0), Vector3f(0,0,10));
!
! Vector3f pos;
! float size;
!
! if (mGameState.GetBall(pos, size))
! {
! mGLServer.DrawCircle(pos, 1.0, 0 , 360);
! }
!
return;
}
***************
*** 694,697 ****
--- 742,786 ----
void
+ Monitor::DrawVelocities()
+ {
+ Vector3f pos, oldpos;
+
+ float timeDiff = mGameState.GetTime() - mOldGameState.GetTime();
+
+ // if no time has passed, no velocity can be calculated
+ // TODO: this should set a default for stop clock cycles
+ if (timeDiff == 0.0)
+ return;
+
+ //glDisable(GL_DEPTH_TEST);
+
+ glColor3f(0.0f, 0.0f, 0.0f);
+
+ if (mGameState.GetBall(pos) && mOldGameState.GetBall(oldpos))
+ {
+ //DrawBall(pos, size, pass);
+ //For scaling must divide by (timeDiff)
+
+ mGLServer.DrawArbitraryLine(pos, pos + (pos-oldpos)/timeDiff);
+ //mGLServer.DrawArbitraryLine(pos, pos + (pos-oldpos)/timeDiff);
+ }
+
+ int i = 0;
+ int unum;
+ TTeamIndex side;
+ float size;
+ while (mGameState.GetPlayer(i, pos, side, unum, size))
+ {
+ mOldGameState.GetPlayer(i, oldpos, side, unum, size);
+ mGLServer.DrawArbitraryLine(pos, pos + (pos-oldpos)/timeDiff);
+ ++i;
+ }
+
+ //glEnable(GL_DEPTH_TEST);
+
+ }
+
+
+ void
Monitor::Display()
{
***************
*** 815,818 ****
--- 904,911 ----
DrawDebug();
+ // JAN
+ if (mDrawVelocity)
+ DrawVelocities();
+
DrawStatusText();
***************
*** 956,960 ****
case 'f' :
// fast
! mRealTime = false;
break;
--- 1049,1055 ----
case 'f' :
// fast
! mRealTime = !mRealTime;
! if (mRealTime)
! mDiffTime=DiffTime();
break;
***************
*** 964,972 ****
mDiffTime = DiffTime() ;
break;
! #if 0
case 'v':
! mCommServer->SendToWorldModel("(ball (pos 49 20 1) (vel 6.0 0.0 0.1))");
break;
! #endif
default:
return;
--- 1059,1068 ----
mDiffTime = DiffTime() ;
break;
!
case 'v':
! mDrawVelocity = !mDrawVelocity;
! //mCommServer->SendToWorldModel("(ball (pos 49 20 1) (vel 6.0 0.0 0.1))");
break;
!
default:
return;
***************
*** 1056,1060 ****
if (DiffTime() - mDiffTime > 0)
{
! cout << DiffTime() << " " << mDiffTime << endl;
if (mRealTime)
--- 1152,1156 ----
if (DiffTime() - mDiffTime > 0)
{
! //cout << DiffTime() << " " << mDiffTime << endl;
if (mRealTime)
***************
*** 1100,1105 ****
--- 1196,1208 ----
mCommServer->GetPredicates();
+ //JAN
+ if (mDrawVelocity)
+ mOldGameState = mGameState;
+
mGameState.ProcessInput(predicates);
+ //cout << "old time = " << mOldGameState.GetTime() << endl;
+ //cout << "new time = " << mGameState.GetTime() << endl;
+
mAdvance = false;
Index: monitor.h
===================================================================
RCS file: /cvsroot//sserver/rcsoccersim/rcssserver3D/app/rcssmonitor3d/lite/monitor.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** monitor.h 24 Jan 2005 12:37:14 -0000 1.8
--- monitor.h 24 May 2005 11:31:16 -0000 1.9
***************
*** 86,89 ****
--- 86,90 ----
static const GLfloat sGroundColor[4];
+ static const GLfloat sGroundColor2D[4];
static const GLfloat sGoalColor[4];
static const GLfloat sBorderColor[4];
***************
*** 121,124 ****
--- 122,126 ----
void DrawBall(const salt::Vector3f& pos, float size, int pass);
void DrawDebug();
+ void DrawVelocities();
long int DiffTime();
***************
*** 132,135 ****
--- 134,141 ----
GLServer mGLServer;
GameState mGameState;
+
+ //JAN
+ GameState mOldGameState;
+
//! the zeitgeist core
zeitgeist::Zeitgeist mZeitgeist;
***************
*** 176,185 ****
//! flag for single step
bool mSingleStep;
//! flag for advancing
bool mAdvance;
bool mRealTime;
long int mDiffTime;
-
-
};
-
--- 182,191 ----
//! flag for single step
bool mSingleStep;
+ //! flag for drawing velocities
+ bool mDrawVelocity;
//! flag for advancing
bool mAdvance;
+ //! flag for real time or fast playback
bool mRealTime;
long int mDiffTime;
};
|