本文整理汇总了C++中Boundary::getLeftPosition方法的典型用法代码示例。如果您正苦于以下问题:C++ Boundary::getLeftPosition方法的具体用法?C++ Boundary::getLeftPosition怎么用?C++ Boundary::getLeftPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Boundary
的用法示例。
在下文中一共展示了Boundary::getLeftPosition方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderWireframe
void WaterPhysicsSystem::renderWireframe()
{
for (unsigned int i = 0; i != edges.size(); i++)
{
Edge* edge = edges[i];
glBegin(GL_LINES);
{
glColor3f(1,1,1);
glVertex2f(edge->aPosition().x, edge->aPosition().y);
glVertex2f(edge->bPosition().x, edge->bPosition().y);
}
glEnd();
glBegin(GL_POINTS);
{
glColor3f(1,0,0);
glVertex2f(edge->aPosition().x, edge->aPosition().y);
glVertex2f(edge->bPosition().x, edge->bPosition().y);
}
glEnd();
}
glColor3f(0,0,1);
for (unsigned int i = 0; i != volumes.size(); i++)
{
Volume* volume = volumes[i];
Vec2f center;
center = volume->getLeft()->aPosition();
center += volume->getLeft()->bPosition();
center += volume->getRight()->aPosition();
center += volume->getRight()->bPosition();
center /= 4.0f;
glBegin(GL_LINES);
{
glVertex2f(volume->getLeft()->aPosition().x, volume->getLeft()->aPosition().y);
glVertex2f(center.x, center.y);
glVertex2f(volume->getRight()->aPosition().x, volume->getRight()->aPosition().y);
glVertex2f(center.x, center.y);
glVertex2f(volume->getRight()->bPosition().x, volume->getRight()->bPosition().y);
glVertex2f(center.x, center.y);
glVertex2f(volume->getLeft()->bPosition().x, volume->getLeft()->bPosition().y);
glVertex2f(center.x, center.y);
}
glEnd();
}
glBegin(GL_LINES);
glColor3f(1,1,0.5f);
// for (Boundary* boundary = boundaries.front(); boundary; boundary = boundary->getNextObject())
for (unsigned int i = 0; i != boundaries.size(); i++)
{
Boundary* boundary = boundaries[i];
if (boundary)
{
Vec2f p = boundary->getLeftPosition();
glVertex2f(p.x, p.y);
p = boundary->getRightPosition();
glVertex2f(p.x, p.y);
}
}
glEnd();
}
示例2: addFinalisedEdge
void WaterPhysicsSystem::addFinalisedEdge(Edge* _edge)
{
edges.push_back(_edge);
Edge::EdgeType type = _edge->getEdgeType();
bool leftEdge;
if (type == Edge::eLeftFloor || type == Edge::eLeftRoof)
{
leftEdge = true;
}
else
{
leftEdge = false;
}
addFinalisedVertex(_edge->getA(), _edge, leftEdge);
addFinalisedVertex(_edge->getB(), _edge, leftEdge);
// for (Boundary* boundary = boundaries.front(); boundary; boundary = boundary->getNextObject())
for (unsigned int i = 0; i != boundaries.size(); i++)
{
Boundary* boundary = boundaries[i];
if (boundary)
try
{
Vec2f position = intersectionPosition(_edge->aPosition(), _edge->bPosition(), boundary->getLeftPosition(), boundary->getRightPosition());
Vertex* vertex = new Vertex(position, nullptr, true);
if (leftEdge)
{
//assert(boundary->getLeft() == nullptr);
boundary->setLeft(vertex);
}
else
{
// assert(boundary->getRight() == nullptr);
boundary->setRight(vertex);
}
}
catch (int i)
{}
}
/*
edges.push_back(_edge);
Vec2f a = _edge->aPosition();
Vertex* vertex = _edge->getA();
bool jump = true;
goto ACTUAL_START;
START:
vertex = _edge->getB();
jump = false;
ACTUAL_START:
Vec2f b;
Edge::EdgeType type = _edge->getEdgeType();
bool leftEdge;
if (type == Edge::eLeftFloor | type == Edge::eLeftRoof)
{
b = a + Vec2f(500, 0);
leftEdge = true;
}
else
{
b = a - Vec2f(500, 0);
leftEdge = false;
}
Edge* opposingEdge = findIntersectingEdge(a, &b, _edge);
if (opposingEdge)
{
Vec2f a2 = opposingEdge->aPosition();
Vec2f b2 = a2 + Vec2f((leftEdge)?-500:500,0);
Edge* opposingOpposingEdge = findIntersectingEdge(a2, &b2, opposingEdge);
if (opposingOpposingEdge == _edge)
{
Edge* selfSplit = _edge->split(b2, nullptr);
edges.push_back(selfSplit);
}
// else
{
a2 = opposingEdge->bPosition();
b2 = a2 + Vec2f((leftEdge)?-500:500,0);
opposingOpposingEdge = findIntersectingEdge(a2, &b2, opposingEdge);
if (opposingOpposingEdge == _edge)
{
Edge* selfSplit = _edge->split(b2, nullptr);
edges.push_back(selfSplit);
}
}
Edge* newEdge = opposingEdge->split(b, nullptr);
edges.push_back(newEdge);
}
if (jump)
{
a = _edge->bPosition();
goto START;
}*/
}