本文整理汇总了C++中Portal::getNeighbors方法的典型用法代码示例。如果您正苦于以下问题:C++ Portal::getNeighbors方法的具体用法?C++ Portal::getNeighbors怎么用?C++ Portal::getNeighbors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Portal
的用法示例。
在下文中一共展示了Portal::getNeighbors方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cullDraw
bool Portal::cullDraw(struct MAZEmat *projviewMat, struct MAZEmat *viewportMat,
struct MAZErectangle &rec, const std::vector<Portal *> *portals, set<int *> &visitedEdgeSet){
MAZEmat finalProjViewMat;
multMat(projviewMat, &transformation, &finalProjViewMat);
//TODO: implement BV for objects
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
//glMultMatrixf(transformation.mat);
if(!portalObj->isHidden())
portalObj->draw(portals);
for(int i=0; i<objs.size(); i++)
if(!objs[i]->isHidden())
objs[i]->draw(portals);
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
//What this portal looks like in its neighbors eye...
int posMap[4] = {1, 0, 3, 2};
for(int i=0; i<4; i++){
if(neighbors[i] < 0)
continue;
//Have we visited this undirected edge?
//I know the following code seems a little hack
//but I can't find any better way...
Portal *port = (*portals)[neighbors[i]];
if(visitedEdgeSet.count(port->getNeighbors()+posMap[i]) > 0 ||
visitedEdgeSet.count(neighbors+i))
continue;
//int size1 = visitedEdgeSet.size();
visitedEdgeSet.insert(neighbors+i);
//int size2 = visitedEdgeSet.size();
/*if(size2 == size1){
cout << "not right" << endl;
}*/
//assert(visitedEdgeSet.size()<4*(*portals).size());
//cout<<"visitedEdge " << visitedEdgeSet.size() << endl;
struct Vec3 p[4];
float left = MY_FLT_MAX, right = MY_FLT_MIN, top = MY_FLT_MIN, bottom = MY_FLT_MAX;
float nearC = MY_FLT_MAX, farC = MY_FLT_MIN;
for(int j=0; j<4; j++){
struct Vec3 tmp;
matMultVec3_normalize(&finalProjViewMat, &doorPoints[i][j], &tmp);
matMultVec3_normalize(viewportMat, &tmp, p+j);
if(p[j].x < left)
left = p[j].x;
if(p[j].x > right)
right = p[j].x;
if(p[j].y > top)
top = p[j].y;
if(p[j].y < bottom)
bottom = p[j].y;
if(p[j].z < nearC)
nearC = p[j].z;
if(p[j].z > farC)
farC = p[j].z;
}
if(farC < 0 || nearC > 1)
continue;
left = left > rec.left ? left : rec.left;
right = right < (rec.left+rec.width) ? right : rec.left+rec.width;
bottom = bottom > rec.bottom ? bottom : rec.bottom;
top = top < (rec.bottom + rec.height) ? top : rec.bottom+rec.height;
MAZErectangle neighborRect;
neighborRect.left = left;
neighborRect.bottom = bottom;
neighborRect.height = top-bottom;
neighborRect.width = right-left;
//This is necessary for edge condition
if(neighborRect.height <= -1e-5 || neighborRect.width <= -1e-5)
continue;
//Door status switched. If it is open from this cell to its
//neighbor, we might visit that neighbor. When we are visiting
//the neighbor, we will close the door and would not visit this
//cell. Is it still possible that we might loop back to visited portal?
//If the door is open, visit it.
//NOTE: Theorectically it's possible that a single object in a cell
//can be rendered several times from different doors. TODO: I might add some
//mask to handle this problem in the future. But, for this maze game,
//this scenario seems unlikely. So ignore it for now.
port->cullDraw(projviewMat, viewportMat, neighborRect, portals, visitedEdgeSet);
}
return true;
}