當前位置: 首頁>>代碼示例>>C++>>正文


C++ AddVertex函數代碼示例

本文整理匯總了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;
}
開發者ID:PatMart,項目名稱:kicad-source-mirror,代碼行數:36,代碼來源:vrml_layer.cpp

示例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;
}
開發者ID:ablimit,項目名稱:hadoopgis,代碼行數:30,代碼來源:driver.c

示例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();
}
開發者ID:Wynjones1,項目名稱:game,代碼行數:32,代碼來源:drawable.cpp

示例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;
	}
開發者ID:segafan,項目名稱:Construct-classic,代碼行數:28,代碼來源:CDX9Renderer_Batch.cpp

示例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);
		}
	}
}
開發者ID:Wynjones1,項目名稱:game,代碼行數:35,代碼來源:drawable.cpp

示例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);
}
開發者ID:jpoirier,項目名稱:GlassCockpit,代碼行數:34,代碼來源:CircleEvaluator.cpp

示例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;
}
開發者ID:mvancompernolle,項目名稱:ai_project,代碼行數:27,代碼來源:FuzzyMembershipFunction.cpp

示例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] );
				}
			}
		}		
	}
}
開發者ID:ana-GT,項目名稱:Homo2D,代碼行數:32,代碼來源:HP2D.cpp

示例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;
        }
    }
開發者ID:kidaa,項目名稱:UnrealEngineVR,代碼行數:27,代碼來源:StaticMeshEdit.cpp

示例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;
}
開發者ID:jerkey,項目名稱:kicad,代碼行數:36,代碼來源:vrml_board.cpp

示例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;
}
開發者ID:jnyabe,項目名稱:lang,代碼行數:31,代碼來源:adj_list.cpp

示例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);
  }
}
開發者ID:lucafuji,項目名稱:Gene-Correlation,代碼行數:34,代碼來源:scnextrude.cpp

示例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);
}
開發者ID:svkaiser,項目名稱:TurokEX,代碼行數:9,代碼來源:cpuVertexList.cpp

示例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
}
開發者ID:CMU-Suter-Group,項目名稱:XDMXX,代碼行數:10,代碼來源:SimpleGraph.tmpl.cpp

示例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++);
}
開發者ID:AnthonyNystrom,項目名稱:NuGenBioChemDX,代碼行數:17,代碼來源:Sphere.cpp


注:本文中的AddVertex函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。