本文整理汇总了C++中AddVertex函数的典型用法代码示例。如果您正苦于以下问题:C++ AddVertex函数的具体用法?C++ AddVertex怎么用?C++ AddVertex使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AddVertex函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: contour
// adds an arc to the given center, start point, pen width, and angle (degrees).
bool VRML_LAYER::AppendArc( double aCenterX, double aCenterY, double aRadius,
double aStartAngle, double aAngle, int aContourID )
{
if( aContourID < 0 || (unsigned int) aContourID >= contours.size() )
{
error = "AppendArc(): invalid contour (out of range)";
return false;
}
aAngle = aAngle / 180.0 * M_PI;
aStartAngle = aStartAngle / 180.0 * M_PI;
int nsides = calcNSides( aRadius, aAngle );
double da = aAngle / nsides;
bool fail = false;
if( aAngle > 0 )
{
aAngle += aStartAngle;
for( double ang = aStartAngle; ang < aAngle; ang += da )
fail |= !AddVertex( aContourID, aCenterX + aRadius * cos( ang ),
aCenterY + aRadius * sin( ang ) );
}
else
{
aAngle += aStartAngle;
for( double ang = aStartAngle; ang > aAngle; ang += da )
fail |= !AddVertex( aContourID, aCenterX + aRadius * cos( ang ),
aCenterY + aRadius * sin( ang ) );
}
return !fail;
}
示例2: add
bool add(int which_poly, int x, int y)
{
bool res = false;
vertex *v;
v = (vertex*)malloc(sizeof(vertex));
v->x = x;
v->y = y;
v->alpha = 0.;
v->internal = false;
v->linkTag = 0;
if (which_poly == 1)
{
v->next = s_size+1 ;
res = AddVertex(s,s_size,v);
}
else if (which_poly == 2)
{
v->next = c_size+1 ;
res = AddVertex(c,c_size,v);
}
else {
printf("%d is not a valid polygon index.\n",which_poly);
exit(1);
}
free(v);
return res;
}
示例3: Drawable
Mesh::Mesh(Program &program)
: Drawable(program)
, vbuffer(-1)
, nbuffer(-1)
, tbuffer(-1)
, fbuffer(-1)
, texture(NULL)
{
AddVertex(-1.0, -1.0, -1.0);
AddVertex(-1.0, 1.0, -1.0);
AddVertex(1.0, 1.0, -1.0);
AddVertex(1.0, -1.0, -1.0);
AddTexcoord(0, 1);
AddTexcoord(0, 0);
AddTexcoord(1, 0);
AddTexcoord(1, 1);
AddColour(1.0, 0.0, 0.0);
AddColour(0.0, 1.0, 0.0);
AddColour(0.0, 0.0, 1.0);
AddColour(1.0, 1.0, 1.0);
AddNormal(0.0, 0.0, 1.0);
AddNormal(0.0, 0.0, 1.0);
AddNormal(0.0, 0.0, 1.0);
AddNormal(0.0, 0.0, 1.0);
AddFace(0, 1, 2);
AddFace(2, 3, 0);
InitBuffers();
}
示例4: SetTexture
void CDX9Renderer::Box(const rect& r, cr_float angle, point hotspot, const color& c)
{
// No support for textured lines
SetTexture(NULL);
quad q((r - hotspot).rotate_to_quad(angle, r.topleft()));
BeginBatch(batch_linestrip);
CBatch_Draw* draw_op = reinterpret_cast<CBatch_Draw*>(batch.back());
D3DCOLOR color = c.getD3DCOLOR();
// 4 vertices and use 5th index to repeat first vertex closing the strip as a box
AddVertex(color, q.tl, 0.0f, 0.0f);
AddVertex(color, q.tr, 0.0f, 0.0f);
AddVertex(color, q.br, 0.0f, 0.0f);
AddVertex(color, q.bl, 0.0f, 0.0f);
unsigned short index = draw_op->vertex_count;
AddIndex(index);
AddIndex(index + 1);
AddIndex(index + 2);
AddIndex(index + 3);
AddIndex(index);
draw_op->vertex_count += 4;
draw_op->index_count += 5;
}
示例5: fgets
void Mesh::ReadVertexData(FILE *fp, int num, bool have_normals, bool have_tex)
{
double n[3];
double v[3];
double t[2];
char buf[1024];
for(int i = 0; i < num; i++)
{
fgets(buf, 1024, fp);
if(have_normals && have_tex)
{
sscanf(buf, "%lf %lf %lf %lf %lf %lf %lf %lf", v, v+1, v+2, n, n+1, n+2, t, t+1);
AddVertex(v);
AddNormal(n);
AddTexcoord(t);
}
else if(have_normals)
{
sscanf(buf, "%lf %lf %lf %lf %lf %lf", v, v+1, v+2, n, n+1, n+2);
AddVertex(v);
AddNormal(n);
}
else if(have_tex)
{
sscanf(buf, "%lf %lf %lf %lf %lf", v, v+1, v+2, t, t+1);
AddVertex(v);
AddTexcoord(t);
}
else
{
sscanf(buf, "%lf %lf %lf", v, v+1, v+2);
AddVertex(v);
}
}
}
示例6: AddVertex
void CircleEvaluator::Evaluate() {
// Add the vertexes specified
double x;
double y;
double pi = 3.14159265;
// We parametrically evaluate the circle
// x = sin(t)
// y = cos(t)
// t goes from 0 to 2pi
// 0 degrees = 0rad, 90 degrees = pi/2rad, etc.
double startRad = m_StartArcDegrees / 180 * pi;
double endRad = m_EndArcDegrees / 180 * pi;
double radPerPoint = m_DegreesPerPoint / 180 * pi;
if (startRad > endRad)
endRad += 2*pi;
double currentRad = startRad;
do {
x = m_Radius*sin(currentRad) + m_XOrigin;
y = m_Radius*cos(currentRad) + m_YOrigin;
AddVertex(x,y);
currentRad += radPerPoint;
} while (currentRad < endRad);
x = m_Radius*sin(endRad) + m_XOrigin;
y = m_Radius*cos(endRad) + m_YOrigin;
AddVertex(x, y);
}
示例7: DeleteVertices
bool CFuzzyMembershipFunction::InitTriangle (long x1, long x2, long x3)
{
if ((x1 < x2) && (x2 < x3))
{
CFuzzyElement FE;
DeleteVertices();
// Left vertex.
FE.SetValue(x1);
FE.SetMembership(0.0);
AddVertex(FE);
// Peak vertex.
FE.SetValue(x2);
FE.SetMembership(1.0);
AddVertex(FE);
// Right vertex.
FE.SetValue(x3);
FE.SetMembership(0.0);
AddVertex(FE);
return true;
}
return false;
}
示例8: printf
/**
* @function BuildManifold
*/
void HP2D::BuildManifold( Vertex* _v0 ) {
Vertex* va;
std::vector<Vertex*> S;
std::vector<Vertex*> B;
printf("Build Manifold \n");
AddVertex( _v0 );
EnQueue( _v0 );
while( mQ.size() != 0 ) {
va = DeQueue();
S = Successors( va );
for( unsigned int i = 0; i < S.size(); ++i ) {
AddVertex( S[i] );
AddEdge( va, S[i] );
if( S[i]->GetDist() < DIST_MAX ) {
EnQueue( S[i] );
}
B = GetAdjacent2( va );
for( unsigned j = 0; j < B.size(); ++j ) {
if( CheckPosNeighbors( B[j], S[i] ) == true ) {
AddEdge( S[i], B[j] );
}
}
}
}
}
示例9: AddTriangle
/** Add triangle to connectivity information */
int32 AddTriangle( const FVector &a, const FVector &b, const FVector &c )
{
// Map vertices
int32 VertexA = AddVertex( a );
int32 VertexB = AddVertex( b );
int32 VertexC = AddVertex( c );
// Make sure triangle is not degenerated
if ( VertexA!=VertexB && VertexB!=VertexC && VertexC!=VertexA )
{
// Setup connectivity info
int32 TriangleIndex = Triangles.Num();
Vertices[ VertexA ].AddTriangleLink( TriangleIndex );
Vertices[ VertexB ].AddTriangleLink( TriangleIndex );
Vertices[ VertexC ].AddTriangleLink( TriangleIndex );
// Create triangle
new ( Triangles ) FMeshConnectivityTriangle( VertexA, VertexB, VertexC );
return TriangleIndex;
}
else
{
// Degenerated triangle
return INDEX_NONE;
}
}
示例10: NewContour
// adds a circle the existing list; if 'hole' is true the contour is
// a hole. Returns true if OK.
bool VRML_LAYER::AddCircle( double x, double y, double rad, int csides, bool hole )
{
int pad = NewContour();
if( pad < 0 )
{
error = "AddCircle(): failed to add a contour";
return false;
}
if( csides < 6 )
csides = CalcNSides( rad, maxdev );
// even numbers give prettier results
if( csides & 1 )
csides += 1;
double da = M_PI * 2.0 / csides;
bool fail = false;
if( hole )
{
for( double angle = 0; angle < M_PI * 2; angle += da )
fail |= !AddVertex( pad, x + rad * cos( angle ), y - rad * sin( angle ) );
}
else
{
for( double angle = 0; angle < M_PI * 2; angle += da )
fail |= !AddVertex( pad, x + rad * cos( angle ), y + rad * sin( angle ) );
}
return !fail;
}
示例11: AddVertex
int AdjList::AddEdge(const Vertex& from, const Vertex& to, int cost)
{
if(!hasVertex(from))
{
AddVertex(from);
}
if(!hasVertex(to))
{
AddVertex(to);
}
for(auto& vinfo: m_vinfoList)
{
if(from == vinfo.m_vertex)
{
for(const auto& edge: vinfo.m_edges)
{
if(edge.m_to == to)
{
return -1; // already added
}
}
vinfo.m_edges.push_back({to, cost});
return GRAPH_OK;
}
}
return GRAPH_ERROR_VERTEX_NOT_FOUND;
}
示例12: AddFacet
void Scene::Extrude (int n, float* x, float* y, float depth,
const Trafo& P, const ColorB* color)
{
int n1 = n-1, n2 = 2*n-2;
// add front and back polygonal with n vertices
// the back polygonal has reverse orientation
Facet &front = AddFacet(n),
&back = AddFacet(n);
if (color) {
front.SetColor(*color);
back.SetColor(*color);
}
// create vertices and link them to facets
int i;
for (i = 0; i < n; i++) {
front(i) = &AddVertex( P * Vertex(x[i],y[i],0.0) );
back(i) = &AddVertex( P * Vertex(x[n1-i],y[n1-i],-depth) );
if (color) {
front[i].SetColor(*color);
back[i].SetColor(*color);
}
}
// create n facets for the sides and link the vertices
for (i = 0; i < n; i++) {
Facet &side = AddFacet(4, front(i), back(n1-i),
back((n2-i)%n), front((i+1)%n) );
if (color) side.SetColor(*color);
}
}
示例13: AddVertex
void kexCpuVertList::AddLine(float x1, float y1, float z1,
float x2, float y2, float z2,
byte r, byte g, byte b, byte a) {
*(roverIndices++) = vertexCount; indiceCount++;
AddVertex(x1, y1, z1, 0, 0, r, g, b, a);
*(roverIndices++) = vertexCount; indiceCount++;
AddVertex(x2, y2, z2, 0, 0, r, g, b, a);
}
示例14: AddVertex
void CSimpleUGraph< ObjT, Compare >::AddEdge( const ObjT &oV1, const ObjT & oV2 )
{
typename boost::graph_traits<Graph>::edge_descriptor e;
bool bAdded;
AddVertex( oV1 ); // should lazy these two - check to see if vertex is there first
AddVertex( oV2 );
Vertex u = oDataToVertexMap[ oV1 ];
Vertex v = oDataToVertexMap[ oV2 ];
boost::tie( e, bAdded ) = add_edge( v, u, oBoostGraph ); // add edge
}
示例15: AddBaseTriangle
/// <summary>
/// Helper function to create a face for the base octahedron.
/// </summary>
/// <param name="mesh">Mesh</param>
/// <param name="p1">Vertex 1.</param>
/// <param name="p2">Vertex 2.</param>
/// <param name="p3">Vertex 3.</param>
void AddBaseTriangle(D3DVECTOR& p1, D3DVECTOR& p2, D3DVECTOR& p3)
{
AddVertex(p1.x, p1.y, p1.z, p1.x, p1.y, p1.z, 0, 0);
AddVertex(p2.x, p2.y, p2.z, p2.x, p2.y, p2.z, 0, 0);
AddVertex(p3.x, p3.y, p3.z, p3.x, p3.y, p3.z, 0, 0);
AddIndex(nextIndex++);
AddIndex(nextIndex++);
AddIndex(nextIndex++);
}