Skip to content

Commit

Permalink
adds -bg option to hrpsys-*
Browse files Browse the repository at this point in the history
git-svn-id: https://hrpsys-base.googlecode.com/svn/trunk@517 a991ac11-fb38-5095-8c12-a1ddb0715245
  • Loading branch information
fkanehiro committed Sep 14, 2012
1 parent 5cbc5e5 commit 9caf193
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 4 deletions.
3 changes: 3 additions & 0 deletions doc/utilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ hrpsys-simulator-jython [project file] [jython script] [options]
-endless never finish simulation<br>
-showsensor show sensor output<br>
-size size specify initial window size<br>
-bg r g b background color
\section hrpsys-simulator-python hrpsys-simulator-python
Expand All @@ -51,6 +52,7 @@ usebbox use bounding boxes instead of actual geometries<br>
endless never finish simulation<br>
showsensor show sensor output<br>
size [size] set window size<br>
bg [r] [g] [b] background color
Note:NameSever and openhrp-model-loader must be running
Expand All @@ -75,6 +77,7 @@ hrpsys-monitor [project file] [-rh rtcName] [-sh rtcName] [-size size]
-rh name of %RTC which provides OpenHRP::RobotHardwareService (default:RobotHardware0)<br>
-sh name of %RTC which provides OpenHRP::StateHolderService (default:StateHolder0)<br>
-size initial window size<br>
-bg r g b background color
Note:NameSever and openhrp-model-loader must be running
Expand Down
10 changes: 7 additions & 3 deletions lib/util/GLsceneBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ GLsceneBase::GLsceneBase(LogManagerBase *i_log) :
m_default_camera->setViewTarget(0,0,0.8);
m_camera = m_default_camera;
m_sem = SDL_CreateSemaphore(0);
m_bgColor[0] = m_bgColor[1] = m_bgColor[2] = 0.0;

hrp::Light::nextId = 2;
}
Expand Down Expand Up @@ -174,9 +175,7 @@ void GLsceneBase::init()
glewInit();
initLights();

//glClearColor(0.4, 0.4, 0.55, 1.0);
//glClearColor(0.2, 0.2, 0.5, 1.0);
glClearColor(0.0, 0.0, 0.0, 1.0);
glClearColor(m_bgColor[0], m_bgColor[1], m_bgColor[2], 0.0);
glEnable(GL_DEPTH_TEST);

glEnable(GL_CULL_FACE);
Expand Down Expand Up @@ -422,3 +421,8 @@ hrp::BodyPtr GLsceneBase::targetObject()
return hrp::BodyPtr();
}
}

void GLsceneBase::setBackGroundColor(float rgb[3])
{
for (int i=0; i<3; i++) m_bgColor[i] = rgb[i];
}
2 changes: 2 additions & 0 deletions lib/util/GLsceneBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ class GLsceneBase : virtual public hrp::World<hrp::ConstraintForceSolver>
void addBody(hrp::BodyPtr i_body);
void maxEdgeLen(double i_len);
hrp::BodyPtr targetObject();
void setBackGroundColor(float rgb[3]);
protected:
enum {REQ_NONE, REQ_CLEAR, REQ_CAPTURE};

Expand All @@ -77,6 +78,7 @@ class GLsceneBase : virtual public hrp::World<hrp::ConstraintForceSolver>
std::string m_fname;
double m_maxEdgeLen;
int m_targetObject;
float m_bgColor[3];
};

#endif
8 changes: 7 additions & 1 deletion util/monitor/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ hrp::BodyPtr createBody(const std::string& name, const ModelItem& mitem,
int main(int argc, char* argv[])
{
if (argc < 2){
std::cerr << "Usage:" << argv[0] << " project.xml [-rh RobotHardwareComponent] [-sh StateHolder component] [-size size]" << std::endl;
std::cerr << "Usage:" << argv[0] << " project.xml [-rh RobotHardwareComponent] [-sh StateHolder component] [-size size] [-bg r g b]" << std::endl;
return 1;
}

Expand All @@ -56,13 +56,18 @@ int main(int argc, char* argv[])

char *rhname = NULL, *shname = NULL;
int wsize = 0;
float bgColor[] = {0,0,0};
for (int i = 2; i<argc; i++){
if (strcmp(argv[i], "-rh")==0){
rhname = argv[++i];
}else if(strcmp(argv[i], "-sh")==0){
shname = argv[++i];
}else if(strcmp(argv[i], "-size")==0){
wsize = atoi(argv[++i]);
}else if(strcmp(argv[i], "-bg")==0){
bgColor[0] = atof(argv[++i]);
bgColor[1] = atof(argv[++i]);
bgColor[2] = atof(argv[++i]);
}
}

Expand Down Expand Up @@ -119,6 +124,7 @@ int main(int argc, char* argv[])
}
//==================== viewer ===============
GLscene scene(&log);
scene.setBackGroundColor(bgColor);

SDLwindow window(&scene, &log, &monitor);
window.init(wsize, wsize);
Expand Down
7 changes: 7 additions & 0 deletions util/simulator/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ int main(int argc, char* argv[])
return 1;
}

float bgColor[]={0,0,0};
for (int i=2; i<argc; i++){
if (strcmp("-nodisplay",argv[i])==0){
display = false;
Expand All @@ -122,6 +123,10 @@ int main(int argc, char* argv[])
}else if(strcmp("-record", argv[i])==0){
record = true;
exitOnFinish = true;
}else if(strcmp("-bg", argv[i])==0){
bgColor[0] = atof(argv[++i]);
bgColor[1] = atof(argv[++i]);
bgColor[2] = atof(argv[++i]);
}
}

Expand All @@ -140,6 +145,7 @@ int main(int argc, char* argv[])
&& strcmp(argv[i], "-max-edge-length")
&& strcmp(argv[i], "-exit-on-finish")
&& strcmp(argv[i], "-record")
&& strcmp(argv[i], "-bg")
){
rtmargv.push_back(argv[i]);
rtmargc++;
Expand Down Expand Up @@ -167,6 +173,7 @@ int main(int argc, char* argv[])
//==================== Viewer setup ===============
LogManager<SceneState> log;
GLscene scene(&log);
scene.setBackGroundColor(bgColor);
scene.showSensors(showsensors);
scene.maxEdgeLen(maxEdgeLen);
scene.showCollision(prj.view().showCollision);
Expand Down
10 changes: 10 additions & 0 deletions util/viewer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ using namespace OpenHRP;

int main(int argc, char *argv[])
{
float bgColor[3];
for (int i=1; i<argc; i++){
if (strcmp(argv[i], "-bg")==0){
bgColor[0] = atof(argv[++i]);
bgColor[1] = atof(argv[++i]);
bgColor[2] = atof(argv[++i]);
}
}

CORBA::ORB_var orb = CORBA::ORB::_nil();

try {
Expand All @@ -39,6 +48,7 @@ int main(int argc, char *argv[])

LogManager<OpenHRP::WorldState> log;
GLscene scene(&log);
scene.setBackGroundColor(bgColor);

OnlineViewer_impl* OnlineViewerImpl
= new OnlineViewer_impl(orb, poa, &scene, &log);
Expand Down

0 comments on commit 9caf193

Please sign in to comment.