本文整理汇总了C++中Map::GetOpenGLCoord方法的典型用法代码示例。如果您正苦于以下问题:C++ Map::GetOpenGLCoord方法的具体用法?C++ Map::GetOpenGLCoord怎么用?C++ Map::GetOpenGLCoord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Map
的用法示例。
在下文中一共展示了Map::GetOpenGLCoord方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenGLDraw
void patrolUnit::OpenGLDraw(const MapProvider *mp, const SimulationInfo *) const
{
GLdouble xx, yy, zz, rad;
Map *map = mp->GetMap();
int posx = x, posy = y;
map->GetOpenGLCoord(posx, posy, xx, yy, zz, rad);
glColor3f(r, g, b);
glBegin(GL_LINE_STRIP);
// glVertex3f(xx, yy+rad/2, zz);
glVertex3f(xx, yy, zz-rad/2);
for (int t = moves.size()-1; t >= 0; t--)
{
posx += ((moves[t]&kE)?1:0) - ((moves[t]&kW)?1:0);
posy += ((moves[t]&kS)?1:0) - ((moves[t]&kN)?1:0);
map->GetOpenGLCoord(posx, posy, xx, yy, zz, rad);
// glVertex3f(xx, yy+rad/2, zz);
glVertex3f(xx, yy, zz-rad/2);
}
glEnd();
map->GetOpenGLCoord(x, y, xx, yy, zz, rad);
glColor3f(r, g, b);
drawSphere(xx, yy, zz, rad);
}
示例2:
void TrailMaxUnit<xyLoc,tDirection,MapEnvironment>::OpenGLDraw( int, MapEnvironment *env, SimulationInfo<xyLoc,tDirection,MapEnvironment>* ) {
GLdouble xx, yy, zz, rad;
Map *m = env->GetMap();
if( current_pos.x >= m->GetMapWidth() || current_pos.y >= m->GetMapHeight() ) {
fprintf( stderr, "Warning: TrailMaxUnit is out of bounds. Could not draw it.\n" );
return;
}
m->GetOpenGLCoord( current_pos.x, current_pos.y, xx, yy, zz, rad );
if( done )
glColor3d( 0., 1., 0. ); // turn green when done
else
glColor3f( r, g, b );
DrawSphere( xx, yy, zz, rad );
// draw the path in front of us
if( pathcache.size() > 0 && !done) {
glBegin(GL_LINE_STRIP);
glVertex3f( xx, yy, zz-rad/2 );
for( unsigned int i = 0; i < pathcache.size(); i++ ) {
m->GetOpenGLCoord( pathcache[i].x, pathcache[i].y, xx, yy, zz, rad );
glVertex3f( xx, yy, zz-rad/2 );
}
glEnd();
}
return;
};
示例3: OpenGLDraw
void MySearchUnit::OpenGLDraw(int , AbsMapEnvironment *ame, AbsMapSimulationInfo *si)
{
GLdouble xx, yy, zz, rad;
Map *map = ame->GetMap();
int posx = loc.x, posy = loc.y;
map->GetOpenGLCoord(posx, posy, xx, yy, zz, rad);
glColor3f(r, g, b);
glBegin(GL_LINE_STRIP);
glVertex3f(xx, yy, zz-rad/2);
for (int t = moves.size()-1; t >= 0; t--)
{
posx += ((moves[t]&kE)?1:0) - ((moves[t]&kW)?1:0);
posy += ((moves[t]&kS)?1:0) - ((moves[t]&kN)?1:0);
map->GetOpenGLCoord(posx, posy, xx, yy, zz, rad);
glVertex3f(xx, yy, zz-rad/2);
}
glEnd();
// draw object
map->GetOpenGLCoord(loc.x, loc.y, xx, yy, zz, rad);
if (onTarget)
{
double perc = (1.0-sqrt(sqrt(abs(sin(targetTime+0.25*si->GetSimulationTime())))));
glColor3f(r*perc, g*perc, b*perc);
}
else
glColor3f(r, g, b);
DrawSphere(xx, yy, zz, rad);
/*
// draw target
if (targetUnit >= 0)
{
si->GetPublicUnitInfo( targetUnit, pui );
xyLoc tloc = pui.currentState;
map->GetOpenGLCoord(tloc.x, tloc.y, xx, yy, zz, rad);
double perc = (1.0-sqrt(sqrt(abs(sin(targetTime+0.25*si->GetSimulationTime())))));
glColor3f(r*perc, g*perc, b*perc);
DrawPyramid(xx, yy, zz, 1.1*rad, 0.75*rad);
}
*/
}
示例4: MyFrameHandler
void MyFrameHandler(unsigned long windowID, unsigned int viewport, void *)
{
if (viewport == 0)
{
unitSims[windowID]->StepTime(stepsPerFrame);
}
if (unitSims[windowID]->GetNumUnits() > 0)
{
if (!unitSims[windowID]->GetPaused())
stepsPerFrame*=1.002;//1.01;//
if (unitSims[windowID]->Done() && recording)
{
recording = false;
// stopRecording();
}
}
if (GetNumPorts(windowID) == unitSims[windowID]->GetNumUnits())
{
unitSims[windowID]->GetEnvironment()->OpenGLDraw();
unitSims[windowID]->OpenGLDraw(viewport);
//measure.OpenGLDraw(unitSims[windowID]->GetEnvironment());
}
else {
unitSims[windowID]->GetEnvironment()->OpenGLDraw();
unitSims[windowID]->OpenGLDraw();
}
if (mouseTracking)
{
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f);
Map *m = unitSims[windowID]->GetEnvironment()->GetMap();
GLdouble x, y, z, r;
m->GetOpenGLCoord(px1, py1, x, y, z, r);
glVertex3f(x, y, z-3*r);
m->GetOpenGLCoord(px2, py2, x, y, z, r);
glVertex3f(x, y, z-3*r);
glEnd();
}
}
示例5: MyFrameHandler
void MyFrameHandler(unsigned long windowID, unsigned int viewport, void *)
{
if (ge)
{
ge->OpenGLDraw();
return;
}
if (viewport == 0)
{
unitSims[windowID]->StepTime(1.0/30.0);
}
// for (unsigned int x = 0; x < astars.size(); x++)
// astars[x].OpenGLDraw();
// astar.OpenGLDraw();
unitSims[windowID]->OpenGLDraw();
//unitSims[windowID]->GetEnvironment()->OpenGLDraw();
if (screenShot)
{
SaveScreenshot(windowID, gDefaultMap);
exit(0);
}
// glTranslatef(0, 0, -0.1);
// glLineWidth(6.0);
// if (ge == 0)
// ge = new GraphEnvironment(GraphSearchConstants::GetGraph(unitSims[windowID]->GetEnvironment()->GetMap()));
// ge->OpenGLDraw();
if (astars.size() > 0)
msa->OpenGLDraw();
if (mouseTracking)
{
glBegin(GL_LINES);
glColor3f(1.0f, 0.0f, 0.0f);
Map *m = unitSims[windowID]->GetEnvironment()->GetMap();
GLdouble x, y, z, r;
m->GetOpenGLCoord(px1, py1, x, y, z, r);
glVertex3f(x, y, z-3*r);
m->GetOpenGLCoord(px2, py2, x, y, z, r);
glVertex3f(x, y, z-3*r);
glEnd();
}
if ((gdh) && (!ma1))
gdh->OpenGLDraw();
if (viewport == 1)
mo->OpenGLDraw();
if (viewport == 2)
mo_g->OpenGLDraw();
if (viewport == 3)
mo_h->OpenGLDraw();
if ((ma1) && (viewport == 0)) // only do this once...
{
ma1->SetColor(0.0, 0.5, 0.0, 0.75);
if (runningSearch1 && !unitSims[windowID]->GetPaused())
{
ma1->SetColor(0.0, 0.0, 1.0, 0.75);
for (int x = 0; x < gStepsPerFrame*4; x++)
{
if (a1.DoSingleSearchStep(path))
{
printf("Solution: moves %d, length %f, %lld nodes, %u on OPEN\n",
(int)path.size(), ma1->GetPathLength(path), a1.GetNodesExpanded(),
a1.GetNumOpenItems());
runningSearch1 = false;
break;
}
}
}
a1.OpenGLDraw();
}
if (ma2)
{
ma2->SetColor(1.0, 0.0, 0.0, 0.5);
if (runningSearch2)
{
ma2->SetColor(1.0, 0.0, 1.0, 0.5);
for (int x = 0; x < gStepsPerFrame; x++)
{
if (a2.DoSingleSearchStep(path))
{
printf("Solution: moves %d, length %f, %lld nodes\n",
(int)path.size(), ma1->GetPathLength(path), a2.GetNodesExpanded());
runningSearch2 = false;
break;
}
}
}
a2.OpenGLDraw();
}
if (0&&(runningSearch1 || runningSearch2 || mouseTracking) && viewport == GetNumPorts(windowID)-1)
{
static int cnt = 0;
char fname[255];
sprintf(fname, "/Users/nathanst/Movies/epea/EPEA%d%d%d", (cnt/100)%10, (cnt/10)%10, cnt%10);
SaveScreenshot(windowID, fname);
//.........这里部分代码省略.........