本文整理汇总了C++中TriangleList::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ TriangleList::push_back方法的具体用法?C++ TriangleList::push_back怎么用?C++ TriangleList::push_back使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TriangleList
的用法示例。
在下文中一共展示了TriangleList::push_back方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: check_triangle
bool Triangulator::check_triangle(Vertex *first, TriangleList &triangles) {
// path is a dot
if (first->next == first)
return true;
// path is a two lines
if (first->next->next == first)
return true;
// path is triangle
if (first->next->next->next == first) {
triangles.push_back(first->index);
triangles.push_back(first->next->index);
triangles.push_back(first->next->next->index);
return true;
}
return false;
}
示例2: splitTriList
void KDTree::splitTriList( TriangleList& l, TriangleList& r, TriangleList& p, float pos )
{
curAxis = splitAxis;
unsigned left, right, coplanar, side;
//Go through every triangle in the triangle list
for(unsigned i = 0; i < p.size(); ++i)
{
Triangle& tri = p[i];
left = right = coplanar = 0;
CountVertPositions(tri, left, right, coplanar, splitAxis, pos);
side = max(left, max(right, coplanar));
if(side == left)
l.push_back(tri);
else if(side == right)
r.push_back(tri);
else if(side == coplanar)
l.push_back(tri);
}
}
示例3: triangle_tree
void triangle_tree(
const Eigen::MatrixXd & V,
const Eigen::MatrixXi & F,
TriTree & tree,
TriangleList & tlist)
{
assert(F.cols() == 3);
tlist.clear();
// Loop over facets
for(int f = 0;f<F.rows();f++)
{
Point3 a(V(F(f,0),0), V(F(f,0),1), V(F(f,0),2));
Point3 b(V(F(f,1),0), V(F(f,1),1), V(F(f,1),2));
Point3 c(V(F(f,2),0), V(F(f,2),1), V(F(f,2),2));
tlist.push_back(Triangle3( a,b,c));
}
// constructs AABB tree
tree.clear();
tree.insert(tlist.begin(),tlist.end());
}
示例4: DeallocateGeometry
//.........这里部分代码省略.........
for (DWORD t = 0; t < numStripIndices - 2; ++t)
{
// Build the triangle that will be added to the buffer
// CHANGED July 25, 2008: the winding order is wrong here
//Triangle tri = { pXIndices[t + 0], pXIndices[t + 1], pXIndices[t + 2] };
Triangle tri = { pXIndices[t + 0], pXIndices[t + 2], pXIndices[t + 1] };
// Convert the triangle into subset-indices by using the lookup table
// we generated before.
tri.index[0] = xIndicesTable.find(tri.index[0])->second;
tri.index[1] = xIndicesTable.find(tri.index[1])->second;
tri.index[2] = xIndicesTable.find(tri.index[2])->second;
// Check to make sure this triangle isn't degenerate. If it is, we can just skip
// this triangle entirely to simplify the geometry.
if (tri.index[0] == tri.index[1] || tri.index[1] == tri.index[2] || tri.index[0] == tri.index[2])
{
// Try to find the winding in the list
std::set<size_t>::iterator currentWinding = windingChanges.find(triangles.size());
// Add this to the winding change list, or remove the change if it's already there
if (currentWinding != windingChanges.end())
windingChanges.erase(currentWinding);
else
windingChanges.insert(triangles.size());
// Don't insert a triangle here
continue;
}
// Add this triangle to the list
triangles.push_back(tri);
}
// Calculate the number of indices we need for the buffer
DWORD numGeometryIndices = (DWORD)(triangles.size() * 3);
// Allocate the destination geometry
Geometry* pGeometry = NULL;
if (APP_ERROR(AllocateGeometry(numVertices, numGeometryIndices, &pGeometry))("Couldn't allocate geometry"))
{
// Erase any geometry we made
DeallocateGeometry(subsetGeometry);
// Get rid of the mesh
pSubsetIB->Unlock();
pSubsetIB->Release();
d3dxMesh->UnlockVertexBuffer();
d3dxMesh->Release();
// Free our device
pd3dDevice->Release();
// Error!
return false;
}
// Copy the vertices needed for this subset into the buffer
GeometryVertex* pVertices = pGeometry->pVertices;
for (XIndicesIterator i = xIndicesTable.begin(); i != xIndicesTable.end(); ++i)
{
GeometryVertex* pCurrentVertex = &pVertices[i->second];
*pCurrentVertex = pXVertices[i->first];
示例5: Render
void Renderer::Render( void )
{
for (unsigned i = 0; i < m_renderUnitList.size(); i++)
{
RenderUnit* renderUnit = m_renderUnitList[i];
unsigned nVerts = renderUnit->m_vb->Size();
unsigned nTriangles = renderUnit->m_ib->Size() / 3;
VsOutList vsOuts(nVerts);
TriangleList triangles;
// 对每个顶点执行VS
for (unsigned j = 0; j < nVerts; j++)
{
vsOuts[j] = renderUnit->m_vs->Main((*renderUnit->m_vb)[j]);
}
// triangle setup (trivial-rejection, clipping)
for (unsigned j = 0; j < nTriangles; j++)
{
Triangle tri;
tri.iV0 = (*renderUnit->m_ib)[3 * j + 0];
tri.iV1 = (*renderUnit->m_ib)[3 * j + 1];
tri.iV2 = (*renderUnit->m_ib)[3 * j + 2];
if (TrivialReject(tri, vsOuts))
{
continue;
}
else if (RemoveBackface(tri, vsOuts, CULL_MODE_CCW))
{
continue;
}
else if (TrivialAccept(tri, vsOuts))
{
triangles.push_back(tri);
}
else
{
// TODO: do clipping here
triangles.push_back(tri);
}
}
int halfRtWidth = m_renderTarget->GetWidth() >> 1;
int halfRtHeight = m_renderTarget->GetHeight() >> 1;
for (unsigned j = 0; j < vsOuts.size(); j++)
{
Vector4& position = vsOuts[j].position;
// perspective-divide
position.x /= position.w;
position.y /= position.w;
position.z /= position.w;
// 转化到屏幕坐标
position.x = ( position.x + 1.0f) * halfRtWidth;
position.y = (-position.y + 1.0f) * halfRtHeight;
}
// 光栅化每个三角形
for (unsigned j = 0; j < triangles.size(); j++)
{
VertexShaderOutput& v0 = vsOuts[triangles[j].iV0];
VertexShaderOutput& v1 = vsOuts[triangles[j].iV1];
VertexShaderOutput& v2 = vsOuts[triangles[j].iV2];
if (renderUnit->m_wireFrame) // fill mode: wireframe
{
int x0 = int(v0.position.x);
int y0 = int(v0.position.y);
int x1 = int(v1.position.x);
int y1 = int(v1.position.y);
int x2 = int(v2.position.x);
int y2 = int(v2.position.y);
DrawLine(x0, y0, x1, y1, 0xFFFFFFFF);
DrawLine(x0, y0, x2, y2, 0xFFFFFFFF);
DrawLine(x1, y1, x2, y2, 0xFFFFFFFF);
}
else // fill mode: solid
{
VertexShaderOutput* sv;
VertexShaderOutput* mv;
VertexShaderOutput* ev;
// 按Y值给三个顶点排序
if (v0.position.y < v1.position.y)
{
sv = &v0;
ev = &v1;
}
else
{
sv = &v1;
ev = &v0;
}
//.........这里部分代码省略.........