11 #include <hrpModel/ModelLoaderUtil.h> 12 #include <hrpModel/Sensor.h> 23 for (
unsigned int i=0;
i<strlen(str);
i++){
24 glutBitmapCharacter(GLUT_BITMAP_9_BY_15, str[
i]);
29 m_showingStatus(false), m_showSlider(false),
31 m_videoWriter(NULL), m_cvImage(NULL), m_log(i_log),
32 m_showFloorGrid(true), m_showInfo(true), m_defaultLights(true),
42 m_sem = SDL_CreateSemaphore(0);
50 SDL_DestroySemaphore(
m_sem);
62 if (!i_camera)
return;
72 for (
unsigned int j=0; j<b->numLinks(); j++){
74 const std::vector<GLcamera *>& cameras = l->
cameras();
75 for (
size_t k=0; k<cameras.size(); k++){
108 glReadBuffer(GL_BACK);
109 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
112 std::ofstream ofs(i_fname, std::ios::out | std::ios::trunc | std::ios::binary );
115 ofs <<
"P6" << std::endl << buf << std::endl <<
"255" << std::endl;
117 ofs.write((
char *)(pixels+
i*
m_width*3), m_width*3);
123 glReadBuffer(GL_BACK);
124 glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
127 char *dst = o_buffer, *src;
129 src = buf + (m_height -1 -
i)*
m_width*3;
138 GLfloat light0pos[] = { 40.0, 60.0, 60.0, 1.0 };
139 GLfloat light1pos[] = { -40.0, -60.0, -60.0, 1.0 };
140 GLfloat light0col[] = { 0.9, 0.9, 1.0, 1.0 };
141 GLfloat light1col[] = { 0.5, 0.4, 0.4, 1.0 };
143 glEnable(GL_LIGHTING);
146 glLightfv(GL_LIGHT0, GL_DIFFUSE, light0col);
148 glLightfv(GL_LIGHT1, GL_DIFFUSE, light1col);
150 glLightfv(GL_LIGHT0, GL_POSITION, light0pos);
151 glLightfv(GL_LIGHT1, GL_POSITION, light1pos);
163 glDisable(GL_LIGHT0);
164 glDisable(GL_LIGHT1);
181 glEnable(GL_DEPTH_TEST);
183 glEnable(GL_CULL_FACE);
186 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
208 s[0] = 10; e[0] = -10;
209 for (
int i=-10;
i<=10;
i++){
214 s[1] = 10; e[1] = -10;
215 for (
int i=-10;
i<=10;
i++){
231 glColor3d(1.0,1.0,1.0);
233 glRasterPos2f(10, h);
237 sprintf(buf,
"Time:%6.3f[s]" , tm);
239 sprintf(buf,
"Time:------[s]");
243 glRasterPos2f(10, h);
247 glRasterPos2f(10, h);
248 sprintf(buf,
"FPS %2.0f(%6zutris)", fps, ntri);
255 glRasterPos2f(10, h);
261 glRasterPos2f(10, h);
264 for (
unsigned int i=0;
i<
m_msgs.size();
i++){
265 glRasterPos2f(10, (
m_msgs.size()-
i)*15);
274 boost::function2<void, hrp::Body *, hrp::Sensor *> callback;
277 if (!glbody) std::cout <<
"dynamic_cast failed" << std::endl;
282 ntri += glbody->
draw();
306 glMatrixMode(GL_MODELVIEW);
311 glDisable(GL_LIGHTING);
317 glMatrixMode(GL_PROJECTION);
321 glMatrixMode(GL_MODELVIEW);
325 glColor4f(0.0,0.0,0.0, 0.5);
329 int x = ((double)index)/(len-1)*(
m_width-20)+10;
330 glRectf(x-5,5,x+5,25);
334 glEnable(GL_LIGHTING);
339 CV_FOURCC(
'D',
'I',
'V',
'X'),
374 for (
unsigned int j=0; j<b->numLinks(); j++){
376 const std::vector<GLcamera *>& cameras = l->
cameras();
377 for (
size_t k=0; k<cameras.size(); k++){
381 cameras[k]->render(
this);
420 WorldBase::addBody(i_body);
451 for (
int j=0; j<3; j++){
452 if (min[j] > mi[j]) min[j] = mi[j];
453 if (max[j] < ma[j]) max[j] = ma[j];
#define SLIDER_SIDE_MARGIN
void setCamera(GLcamera *i_camera)
GLcamera * m_default_camera
void divideLargeTriangles(double maxEdgeLen)
virtual void updateScene()=0
GLsceneBase(LogManagerBase *i_log)
void setBackGroundColor(float rgb[3])
png_infop png_charpp name
boost::function2< void, hrp::Body *, hrp::Sensor * > getSensorDrawCallback()
std::vector< std::string > m_msgs
const std::vector< GLcamera * > & cameras()
const std::string & name() const
GLcamera * getDefaultCamera()
void setViewTarget(double x, double y, double z)
void computeAABB(hrp::Vector3 &o_min, hrp::Vector3 &o_max)
size_t drawObjects(bool showSensors=true)
boost::shared_ptr< Body > BodyPtr
void setView(int w, int h)
int gettimeofday(struct timeval *tv, struct timezone *tz)
void setViewPoint(double x, double y, double z)
virtual int updateIndex()=0
void addBody(hrp::BodyPtr i_body)
const std::string & name()
virtual double currentTime()=0
void save(const char *i_fname)
static void drawString(const char *str)
virtual void showStatus()
void requestCapture(const char *i_fname)
void setScreenSize(int w, int h)
hrp::BodyPtr targetObject()
std::string sprintf(char const *__restrict fmt,...)
void drawInfo(double fps, size_t ntri)
void maxEdgeLen(double i_len)
void setSensorDrawCallback(boost::function2< void, hrp::Body *, hrp::Sensor *> f)
virtual unsigned int length()=0
virtual void drawAdditionalLines()
CvVideoWriter * m_videoWriter
struct timeval m_lastDraw