您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ triangle函数代码示例

51自学网 2021-06-03 08:58:38
  C++
这篇教程C++ triangle函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中triangle函数的典型用法代码示例。如果您正苦于以下问题:C++ triangle函数的具体用法?C++ triangle怎么用?C++ triangle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了triangle函数的27个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: quad

 void quad(T const& a, T const& b, T const& c, T const& d) {   triangle(a, b, c);   triangle(a, c, d); }
开发者ID:wibbe,项目名称:slg,代码行数:5,


示例2: four_tetras

static voidfour_tetras (GL_VECTOR *outer, Bool wireframe_p, int countdown){  if (countdown <= 0)    {      triangle (outer[0].x, outer[0].y, outer[0].z,                outer[1].x, outer[1].y, outer[1].z,                outer[2].x, outer[2].y, outer[2].z,                wireframe_p);      triangle (outer[0].x, outer[0].y, outer[0].z,                outer[3].x, outer[3].y, outer[3].z,                outer[1].x, outer[1].y, outer[1].z,                wireframe_p);      triangle (outer[0].x, outer[0].y, outer[0].z,                outer[2].x, outer[2].y, outer[2].z,                outer[3].x, outer[3].y, outer[3].z,                wireframe_p);      triangle (outer[1].x, outer[1].y, outer[1].z,                outer[3].x, outer[3].y, outer[3].z,                outer[2].x, outer[2].y, outer[2].z,                wireframe_p);    }  else    {#     define M01 0#     define M02 1#     define M03 2#     define M12 3#     define M13 4#     define M23 5      GL_VECTOR inner[M23+1];      GL_VECTOR corner[4];      inner[M01].x = (outer[0].x + outer[1].x) / 2.0;      inner[M01].y = (outer[0].y + outer[1].y) / 2.0;      inner[M01].z = (outer[0].z + outer[1].z) / 2.0;      inner[M02].x = (outer[0].x + outer[2].x) / 2.0;      inner[M02].y = (outer[0].y + outer[2].y) / 2.0;      inner[M02].z = (outer[0].z + outer[2].z) / 2.0;      inner[M03].x = (outer[0].x + outer[3].x) / 2.0;      inner[M03].y = (outer[0].y + outer[3].y) / 2.0;      inner[M03].z = (outer[0].z + outer[3].z) / 2.0;      inner[M12].x = (outer[1].x + outer[2].x) / 2.0;      inner[M12].y = (outer[1].y + outer[2].y) / 2.0;      inner[M12].z = (outer[1].z + outer[2].z) / 2.0;      inner[M13].x = (outer[1].x + outer[3].x) / 2.0;      inner[M13].y = (outer[1].y + outer[3].y) / 2.0;      inner[M13].z = (outer[1].z + outer[3].z) / 2.0;      inner[M23].x = (outer[2].x + outer[3].x) / 2.0;      inner[M23].y = (outer[2].y + outer[3].y) / 2.0;      inner[M23].z = (outer[2].z + outer[3].z) / 2.0;      countdown--;      corner[0] = outer[0];      corner[1] = inner[M01];      corner[2] = inner[M02];      corner[3] = inner[M03];      four_tetras (corner, wireframe_p, countdown);      corner[0] = inner[M01];      corner[1] = outer[1];      corner[2] = inner[M12];      corner[3] = inner[M13];      four_tetras (corner, wireframe_p, countdown);      corner[0] = inner[M02];      corner[1] = inner[M12];      corner[2] = outer[2];      corner[3] = inner[M23];      four_tetras (corner, wireframe_p, countdown);      corner[0] = inner[M03];      corner[1] = inner[M13];      corner[2] = inner[M23];      corner[3] = outer[3];      four_tetras (corner, wireframe_p, countdown);    }}
开发者ID:Bluerise,项目名称:bitrig-xenocara,代码行数:84,


示例3: triangle

void Bitmap::DrawTriangle(const Triangle &tr, color_t color){	triangle(_alBitmap,		tr.X1, tr.Y1, tr.X2, tr.Y2, tr.X3, tr.Y3, color);}
开发者ID:adventuregamestudio,项目名称:ags,代码行数:5,


示例4: generate_triangles

TArray<FVector> generate_triangles() {	triangle(FVector(1000, 0, 0), FVector(0, 0, 0), FVector(500, 0, 1000));	return triangle(FVector(500, 0, 0), FVector(0, 0, 0), FVector(500, 0, 1000));}
开发者ID:JBisnett,项目名称:oculustest,代码行数:4,


示例5: projectWithEigen

cv::Mat projectWithEigen(){	// Transform meshes into camera frame	// For each frame in vector	for (int frame = 0; frame < mMeshFrameIDs.size(); frame++)	{		// Lookup current transform		Eigen::Isometry3 transform;		transform = transforms.at(mMeshFrameIDs[frame]);		// Get copy of mesh for each frame		ap::Mesh* sourceMesh;		ap::Mesh* transformedMesh;		//std::cerr << "Getting frame " << frame << " : " << mMeshFrameIDs[frame] << std::endl;		MeshMap::iterator scene_i = scenes.find(mMeshFrameIDs[frame]);		if (scenes.end() == scene_i) { continue; }		sourceMesh = scene_i->second;		MeshMap::iterator scene_t = transformedScenes.find(mMeshFrameIDs[frame]);		if (transformedScenes.end() == scene_t) { continue; }		transformedMesh = scene_t->second;		// Transform mesh into camera frame		for (int i = 0; i < sourceMesh->vertices.size(); i++)		{			Eigen::Vector3 newVertex = transform * sourceMesh->vertices[i];			//std::cerr << mesh->vertices[i].transpose() << "/t->/t" << newVertex.transpose() << std::endl;			transformedMesh->vertices[i] = newVertex;		}	}	// For each pixel in camera image	cv::Mat robotImage(mCameraModel.cameraInfo().height, mCameraModel.cameraInfo().width, CV_32F);	float* pixelPtr = (float*)robotImage.data;	float maxDepth = 0;	for (int v = 0; v < robotImage.rows; v++)	{		for (int u = 0; u < robotImage.cols; u++)		{			// Create a ray through the pixel			int pixelIdx = u + (v * robotImage.cols);			//std::cerr << "Pixel (" << u << "," << v << ")" << std::endl;			cv::Point2d pixel = cv::Point2d(u, v);			cv::Point3d cvRay = mCameraModel.projectPixelTo3dRay(pixel);			// Convert cvRay to ap::Ray			ap::Ray ray;			ray.point = Eigen::Vector3::Zero();			ray.vector.x() = cvRay.x; ray.vector.y() = cvRay.y; ray.vector.z() = cvRay.z;			ray.vector.normalize();			//std::cerr << ray.vector.transpose() << std::endl;			// For each frame in vector			for (int frame = 0; frame < mMeshFrameIDs.size(); frame++)			{				MeshMap::iterator scene_i = transformedScenes.find(mMeshFrameIDs[frame]);				if (transformedScenes.end() == scene_i)				{					continue;				}				ap::Mesh* mesh = scene_i->second;				// For each triangle in mesh				for (int i = 0; i < mesh->faces.size(); i++)				{					// Check for intersection. If finite, set distance					ap::Triangle triangle(mesh->vertices[mesh->faces[i].vertices[0]],										  mesh->vertices[mesh->faces[i].vertices[1]],										  mesh->vertices[mesh->faces[i].vertices[2]]);					Eigen::Vector3 intersection = ap::intersectRayTriangle(ray, triangle);					if (std::isfinite(intersection.x()))					{						float d = intersection.norm();						float val = pixelPtr[pixelIdx];						if (val == 0 || val > d)						{							pixelPtr[pixelIdx] = d;						}						if (d > maxDepth)						{							maxDepth = d;						}					}				}			}		}	}	// Return the matrix	if (maxDepth == 0) { maxDepth = 1;}	return robotImage/maxDepth;}
开发者ID:a-price,项目名称:ap_robot_utils,代码行数:94,


示例6: DBG

  void BVH4mbBuilder::computePrimRefsTrianglesMB(const size_t threadID, const size_t numThreads)   {    DBG(PING);    const size_t numGroups = scene->size();    const size_t startID = (threadID+0)*numPrimitives/numThreads;    const size_t endID   = (threadID+1)*numPrimitives/numThreads;        PrimRef *__restrict__ const prims     = this->prims;    // === find first group containing startID ===    unsigned int g=0, numSkipped = 0;    for (; g<numGroups; g++) {             if (unlikely(scene->get(g) == NULL)) continue;      if (unlikely(scene->get(g)->type != TRIANGLE_MESH)) continue;      const TriangleMeshScene::TriangleMesh* __restrict__ const mesh = scene->getTriangleMesh(g);      if (unlikely(!mesh->isEnabled())) continue;      if (unlikely(mesh->numTimeSteps == 1)) continue;      const size_t numTriangles = mesh->numTriangles;      if (numSkipped + numTriangles > startID) break;      numSkipped += numTriangles;    }    // === start with first group containing startID ===    mic_f bounds_scene_min((float)pos_inf);    mic_f bounds_scene_max((float)neg_inf);    mic_f bounds_centroid_min((float)pos_inf);    mic_f bounds_centroid_max((float)neg_inf);    unsigned int num = 0;    unsigned int currentID = startID;    unsigned int offset = startID - numSkipped;    __align(64) PrimRef local_prims[2];    size_t numLocalPrims = 0;    PrimRef *__restrict__ dest = &prims[currentID];    for (; g<numGroups; g++)     {      if (unlikely(scene->get(g) == NULL)) continue;      if (unlikely(scene->get(g)->type != TRIANGLE_MESH)) continue;      const TriangleMeshScene::TriangleMesh* __restrict__ const mesh = scene->getTriangleMesh(g);      if (unlikely(!mesh->isEnabled())) continue;      if (unlikely(mesh->numTimeSteps == 1)) continue;      for (unsigned int i=offset; i<mesh->numTriangles && currentID < endID; i++, currentID++)	       { 			    	//DBG_PRINT(currentID);	const TriangleMeshScene::TriangleMesh::Triangle& tri = mesh->triangle(i);	prefetch<PFHINT_L2>(&tri + L2_PREFETCH_ITEMS);	prefetch<PFHINT_L1>(&tri + L1_PREFETCH_ITEMS);	const float *__restrict__ const vptr0 = (float*)&mesh->vertex(tri.v[0]);	const float *__restrict__ const vptr1 = (float*)&mesh->vertex(tri.v[1]);	const float *__restrict__ const vptr2 = (float*)&mesh->vertex(tri.v[2]);	const mic_f v0 = broadcast4to16f(vptr0);	const mic_f v1 = broadcast4to16f(vptr1);	const mic_f v2 = broadcast4to16f(vptr2);	const mic_f bmin = min(min(v0,v1),v2);	const mic_f bmax = max(max(v0,v1),v2);	bounds_scene_min = min(bounds_scene_min,bmin);	bounds_scene_max = max(bounds_scene_max,bmax);	const mic_f centroid2 = bmin+bmax;	bounds_centroid_min = min(bounds_centroid_min,centroid2);	bounds_centroid_max = max(bounds_centroid_max,centroid2);	store4f(&local_prims[numLocalPrims].lower,bmin);	store4f(&local_prims[numLocalPrims].upper,bmax);		local_prims[numLocalPrims].lower.a = g;	local_prims[numLocalPrims].upper.a = i;	//DBG_PRINT( local_prims[numLocalPrims] );	numLocalPrims++;	if (unlikely(((size_t)dest % 64) != 0) && numLocalPrims == 1)	  {	    *dest = local_prims[0];	    dest++;	    numLocalPrims--;	  }	else	  {	    const mic_f twoAABBs = load16f(local_prims);	    if (numLocalPrims == 2)	      {		numLocalPrims = 0;		store16f_ngo(dest,twoAABBs);		dest+=2;	      }	  }	      }      if (currentID == endID) break;      offset = 0;    }    /* is there anything left in the local queue? */    if (numLocalPrims % 2 != 0)      *dest = local_prims[0];//.........这里部分代码省略.........
开发者ID:jamesvecore,项目名称:embree,代码行数:101,


示例7: triangle

void Bitmap::p4(P2 p1, P2 p2, P2 p3, P2 p4) {    triangle(p1, p2, p3);    triangle(p1, p2, p4);}
开发者ID:prylee,项目名称:Bitmap,代码行数:4,


示例8: display

static void display(void) {    glClear(GL_COLOR_BUFFER_BIT);    glEnable (GL_LINE_SMOOTH);    glEnable (GL_BLEND);    glEnable (GL_POLYGON_SMOOTH);    glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);    glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);        glColor3f(0.6,0.3,0.0);    rectangle(GL_QUADS);    glColor3f(1.0,1.0,1.0);    glEnable(GL_LINE_STIPPLE);    glLineStipple(1, 0xF0F0);    glLineWidth(3.0f);    glBegin(GL_LINE_LOOP);        glVertex2f(-1,-0.7);        glVertex2f(1,-0.7);        glVertex2f(1,-0.1);        glVertex2f(-1,-0.1);    glEnd();    glColor3f(1.0,1.0,1.0);    glPushMatrix();        glTranslatef(-.65,-.15,0);        glColor3f(0.2,1.0,.2);        triangle();    glPopMatrix();    glPushMatrix();        glTranslatef(-.65,.95,0);        glColor3f(0.0,0.0,0.0);        triangle();     glPopMatrix();    glPushMatrix();        glColor3f(0.0,0.0,0.0);        glTranslatef(0.0,.78,0.0);        drawCircle(0.18f);    glPopMatrix();    glPushMatrix();        glColor3f(1.0,0.0,0.0);        glTranslatef(0.0,-0.3,0.0);        drawCircle(0.18f);    glPopMatrix();    glPushMatrix();    glTranslatef(0.0,-0.05,0.0);    glScalef(0.08,0.007,0.08);    //glPointSize(0.5f);    glBegin(GL_POINTS);    for (float i=-19.0f; i < 109.5f; i += .5f) {        glColor3f(0,i*.1,i*-.1);        glVertex2f(i,sin(i)*3);    }    glEnd();    glPopMatrix();    glPushMatrix();    char* string = "Brian Gianforcaro - RIT 2008/2009";    int len = (int) strlen(string);    glColor3f(1.0,1.0,1.0);    glRasterPos2f(-0.4,1.05);    for (int i = 0; i < len; i++) {        glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_10, string[i]);    }    glPopMatrix();    glPushMatrix();    glTranslatef(0.45,-.54,0);        glEnable(GL_POLYGON_STIPPLE);        glPolygonStipple(stippleBits);        glBegin(GL_POLYGON);            glColor3f(1.0,0,0);            glVertex2f(0,0);            glColor3f(0,1.0,0);            glVertex2f(.4,0);            glColor3f(0,0,1.0);            glVertex2f(.4,.4);            glColor3f(1.0,1.0,1.0);            glVertex2f(0,.4);        glEnd();    glPopMatrix();    glDisable(GL_POLYGON_STIPPLE);    glColor3f(0,0,0);    glPushMatrix();        glTranslatef(0.45,.56,0);        glBegin(GL_POLYGON);            glVertex2f(0,0);            glVertex2f(.4,0);            glVertex2f(.4,.4);            glVertex2f(0,.4);        glEnd();    glPopMatrix();    glColor3f(1,1,1);//.........这里部分代码省略.........
开发者ID:bgianfo,项目名称:computer-graphics,代码行数:101,


示例9: setGLPositions

  void   RTriangleMesh::init(const std::tr1::shared_ptr<magnet::thread::TaskQueue>& systemQueue)  {    RTriangles::init(systemQueue);    //Send the data we already have    setGLPositions(_vertices);    setGLElements(_elements);    {//Calculate the normal vectors      std::vector<float> VertexNormals(_vertices.size(), 0);          //For every triangle, add the cross product of the two edges. We      //then renormalize the normal to get a      //"weighted-by-the-triangle-size" normal.          for (size_t triangle(0); triangle < _elements.size() / 3; ++triangle)	{	  //Grab the vertex IDs	  size_t v1(_elements[3 * triangle + 0]),	    v2(_elements[3 * triangle + 1]),	    v3(_elements[3 * triangle + 2]);		  Vector V1(_vertices[3 * v1 + 0],		    _vertices[3 * v1 + 1],		    _vertices[3 * v1 + 2]),	    V2(_vertices[3 * v2 + 0],	       _vertices[3 * v2 + 1],	       _vertices[3 * v2 + 2]),	    V3(_vertices[3 * v3 + 0],	       _vertices[3 * v3 + 1],	       _vertices[3 * v3 + 2]);	  Vector norm = (V2-V1)^(V3-V2);		  for (size_t i(0); i < 3; ++i)	    {	      VertexNormals[3 * v1 + i] += norm[i];	      VertexNormals[3 * v2 + i] += norm[i];	      VertexNormals[3 * v3 + i] += norm[i];	    }	}      //Now normalize those vertices      for (size_t vert(0); vert < _vertices.size() / 3; ++vert)	{	  double norm 	    = VertexNormals[3 * vert + 0] * VertexNormals[3 * vert + 0]	    + VertexNormals[3 * vert + 1] * VertexNormals[3 * vert + 1]	    + VertexNormals[3 * vert + 2] * VertexNormals[3 * vert + 2];		  if (norm)	    {	      double factor = 1 / std::sqrt(norm);	      VertexNormals[3 * vert + 0] *= factor;	      VertexNormals[3 * vert + 1] *= factor;	      VertexNormals[3 * vert + 2] *= factor;	    }	  else	    {	      VertexNormals[3 * vert + 0] = 1;	      VertexNormals[3 * vert + 1] = 0;	      VertexNormals[3 * vert + 2] = 0;	    }	}      setGLNormals(VertexNormals);    }      //Reclaim some memory    _vertices.clear();    _elements.clear();  }
开发者ID:MarkRunWu,项目名称:DynamO,代码行数:73,


示例10: triangle

//----------------------------------------------------------void ofPath::triangle(const ofPoint & p1, const ofPoint & p2, const ofPoint & p3){	triangle(p1.x,p1.y,p1.z,p2.x,p2.y,p2.z,p3.x,p3.y,p3.z);}
开发者ID:allan-takuya,项目名称:openFrameworks,代码行数:4,


示例11: meshPSLG

bool TriangleMesherInterface :: meshPSLG(const Triangle_PSLG &pslg,                                         const IntArray &outside, const IntArray &inside,                                         std :: vector< FloatArray > &nodes, std :: vector< IntArray > &n_markers,                                         std :: vector< IntArray > &triangles, IntArray &t_markers,                                         std :: vector< IntArray > &segments, IntArray &s_markers) const{#ifdef __TRIANGLE_MODULE    // 1. Fill the struct for triangle;    struct triangulateio mesh;    clearTriangulateIO(mesh);    // 1.a. Copy over the node data.    mesh.numberofpoints = pslg.nx.giveSize();    mesh.pointlist = new REAL [ mesh.numberofpoints * 2 ];    //mesh.pointmarkerlist = new REAL[mesh.numberofpoints];    for ( int i = 0; i < mesh.numberofpoints; ++i ) {        mesh.pointlist [ i * 2 ] = pslg.nx(i);        mesh.pointlist [ i * 2 + 1 ] = pslg.ny(i);        //mesh.pointmarkerlist[i] = pslg.n_marker(i);    }    // 1.b. Copy over the segment data    printf("Copying segment data/n");    mesh.numberofsegments = pslg.segment_a.giveSize();    mesh.segmentlist = new int [ mesh.numberofsegments * 2 ];    for ( int i = 0; i < mesh.numberofsegments; ++i ) {        mesh.segmentlist [ i * 2 ] = pslg.segment_a(i);        mesh.segmentlist [ i * 2 + 1 ] = pslg.segment_b(i);    }    if ( pslg.segment_marker.giveSize() > 0 ) {        mesh.segmentmarkerlist = new int [ mesh.numberofsegments ];        for ( int i = 0; i < mesh.numberofsegments; ++i ) {            mesh.segmentmarkerlist [ i ] = pslg.segment_marker(i);        }    }    // 2. Triangulate    char options [ 100 ];    // Note: Not sure if -A is necessary when using the library interface.    sprintf(options, "-p -q %f -a%f %s -A", this->minAngle, this->maxArea, this->quadratic ? "-o2" : "");    struct triangulateio output;    clearTriangulateIO(output);    custom_triangulate( options, & mesh, & output, NULL, outside.givePointer(), inside.givePointer() );    // 3. Copy back    nodes.resize(output.numberofpoints);    //n_markers.resize(output.numberofpoints);    for ( int i = 0; i < output.numberofpoints; ++i ) {        nodes [ i ].resize(2);        nodes [ i ].at(1) = output.pointlist [ i * 2 ];        nodes [ i ].at(2) = output.pointlist [ i * 2 + 1 ];        //n_markers(i) = output.pointmarkerlist[i]; // Not enough.    }    triangles.resize(output.numberoftriangles);    t_markers.resize(output.numberoftriangles);    for ( int i = 0; i < output.numberoftriangles; ++i ) {        IntArray &triangle = triangles [ i ];        triangle.resize(output.numberofcorners);        for ( int j = 0; j < 3; j++ ) { // First three            triangle(j) = output.trianglelist [ i * output.numberofcorners + j ];        }        // Rearrange the strange ordering of the edge nodes.        if ( output.numberofcorners == 6 ) {            triangle(3) = output.trianglelist [ i * output.numberofcorners + 5 ];            triangle(4) = output.trianglelist [ i * output.numberofcorners + 3 ];            triangle(5) = output.trianglelist [ i * output.numberofcorners + 4 ];        }        t_markers.at(i + 1) = ( int ) round(output.triangleattributelist [ i ]);    }    // A somewhat annoying missing feature of triangle, it won't make the segments quadratic.    std :: set< std :: size_t > *node_triangle = NULL;    if ( this->quadratic ) {        node_triangle = new std :: set< std :: size_t > [ output.numberofpoints ];        for ( std :: size_t i = 0; i < triangles.size(); ++i ) {            IntArray &triangle = triangles [ i ];            for ( int j = 1; j <= 3; ++j ) {                node_triangle [ triangle.at(j) - 1 ].insert(i);            }        }    }    segments.resize(output.numberofsegments);    s_markers.resize(output.numberofsegments);    for ( int i = 0; i < output.numberofsegments; ++i ) {        IntArray &segment = segments [ i ];        segment.resize(this->quadratic ? 3 : 2);        segment.at(1) = output.segmentlist [ i * 2 + 0 ];        segment.at(2) = output.segmentlist [ i * 2 + 1 ];        //segment->at(3) = output.segmentlist[i*3 + 2]; // Quadratic meshes only, not for segments.        if ( this->quadratic ) {            int a, b, c;            std :: set< std :: size_t >tris = node_triangle [ segment.at(1) - 1 ];            // Now look up any triangle with the other point included.            for ( auto tri: tris ) {                IntArray &triangle = triangles [ tri ];                if ( ( b = triangle.findFirstIndexOf( segment.at(2) ) ) > 0 ) {                    a = triangle.findFirstIndexOf( segment.at(1) );//.........这里部分代码省略.........
开发者ID:Micket,项目名称:oofem,代码行数:101,


示例12: draw_triangles

static voiddraw_triangles (ModeInfo *mi, GLfloat fold_ratio, GLfloat stel_ratio){  planetstruct *gp = &planets[MI_SCREEN(mi)];  Bool wire = MI_IS_WIREFRAME(mi);  GLfloat h = sqrt(3) / 2;  GLfloat c = h / 3;  glTranslatef (0, -h/3, 0);  /* Center on face 12 */  /* When closed, center on midpoint of icosahedron. Eyeballed this. */  glTranslatef (0, 0, fold_ratio * 0.754);  glFrontFace (GL_CCW);  /* Adjust the texture matrix so that it has the same coordinate space     as the model. */  glMatrixMode(GL_TEXTURE);  glPushMatrix();  {    GLfloat texw = 5.5;    GLfloat texh = 3 * h;    GLfloat midx = 2.5;    GLfloat midy = 3 * c;    glScalef (1/texw, -1/texh, 1);    glTranslatef (midx, midy, 0);  }  glMatrixMode(GL_MODELVIEW);  /* Front faces */  if (wire)    glDisable (GL_TEXTURE_2D);  else if (do_texture)    {      glEnable (GL_TEXTURE_2D);      glBindTexture (GL_TEXTURE_2D, gp->tex1);    }  else    glDisable (GL_TEXTURE_2D);  triangle (mi, 12, True, fold_ratio, stel_ratio);  /* Back faces */  if (wire)    glDisable (GL_TEXTURE_2D);  else if (do_texture)    {      glEnable (GL_TEXTURE_2D);      glBindTexture (GL_TEXTURE_2D, gp->tex2);    }  else    glDisable (GL_TEXTURE_2D);  glFrontFace (GL_CW);  triangle (mi, 12, False, fold_ratio, 0);  glMatrixMode(GL_TEXTURE);  glPopMatrix();  glMatrixMode(GL_MODELVIEW);}
开发者ID:Ro6afF,项目名称:XScreenSaver,代码行数:66,


示例13: triangle

/* The segments, numbered arbitrarily from the top left:             ________         _      ________             /      //      // /    |/      /              / 0  /  /    /  /3>   | / 5  /               /  / 1  /  / 2  /| ..|4 /  /-6-..     ___________//______//______//______//______/    |   //      //      //      //      //       |7 /  / 9  /  / 11 /  / 13 /  / 15 /  /      | / 8  /  / 10 /  / 12 /  / 14 /  / 16 /     |/______//______//______//______//______/     /      //      /       //      //      / 17 /  / 18 /       /  / 20 /  /       /  /    /  /       / 19 /  / 21 /        //      //       /______//______/   Each triangle can be connected to at most two other triangles.   We start from the middle, #12, and work our way to the edges.   Its centroid is 0,0. */static voidtriangle (ModeInfo *mi, int which, Bool frontp,           GLfloat fold_ratio, GLfloat stel_ratio){  planetstruct *gp = &planets[MI_SCREEN(mi)];  const GLfloat fg[3] = { 1, 1, 1 };  const GLfloat bg[3] = { 0.3, 0.3, 0.3 };  int a = -1, b = -1;  GLfloat max = acos (sqrt(5)/3);  GLfloat rot = -max * fold_ratio / (M_PI/180);  Bool wire = MI_IS_WIREFRAME(mi);  if (wire)    glColor3fv (fg);  switch (which) {  case 3:				/* One third of the face. */    triangle0 (mi, frontp, stel_ratio, 1<<3 | 1<<4);    break;  case 4:				/* Two thirds of the face: convex. */    triangle0 (mi, frontp, stel_ratio, 1<<1 | 1<<2 | 1<<3 | 1<<4);    break;  case 6:				/* One half of the face. */    triangle0 (mi, frontp, stel_ratio, 1<<1 | 1<<2 | 1<<3);    break;  case 7:				/* One half of the face. */    triangle0 (mi, frontp, stel_ratio, 1<<2 | 1<<3 | 1<<4);    break;  default:				/* Full face. */    triangle0 (mi, frontp, stel_ratio, 0x3F);    break;  }  if (wire)    {      char tag[20];      glColor3fv (bg);      sprintf (tag, "%d", which);      glPushMatrix();      glTranslatef (-0.1, 0.2, 0);      glScalef (0.005, 0.005, 0.005);      print_texture_string (gp->font_data, tag);      glPopMatrix();      mi->polygon_count++;    }  /* The connection hierarchy of the faces starting at the middle, #12. */  switch (which) {  case  0: break;  case  1: a =  0; b = -1; break;  case  2: a = -1; b =  3; break;  case  3: break;  case  4: a = -1; b =  5; break;  case  5: a = -1; b =  6; break;  case  7: break;  case  6: break;  case  8: a = 17; b =  7; break;  case  9: a =  8; b = -1; break;  case 10: a = 18; b =  9; break;  case 11: a = 10; b =  1; break;  case 12: a = 11; b = 13; break;  case 13: a =  2; b = 14; break;  case 14: a = 15; b = 20; break;  case 15: a =  4; b = 16; break;  case 16: break;  case 17: break;  case 18: break;  case 19: break;  case 20: a = 21; b = 19; break;  case 21: break;  default: abort(); break;  }  if (a != -1)    {      glPushMatrix();      glTranslatef (-0.5, 0, 0);	/* Move model matrix to upper left */      glRotatef (60, 0, 0, 1);      glTranslatef ( 0.5, 0, 0);//.........这里部分代码省略.........
开发者ID:Ro6afF,项目名称:XScreenSaver,代码行数:101,


示例14: desenha_rede

//.........这里部分代码省略.........    flecha *a_tl = rede->tl,           *a_lt = rede->lt;    /* Inicializacao Allegro */    if(install_allegro(SYSTEM_NONE, &errno, atexit)!=0)        exit(EXIT_FAILURE);    set_color_depth(16);    get_palette(pal);    buff = create_bitmap(IMG_X,IMG_Y);    smaller = (float)IMG_X;    if(smaller > (float)IMG_Y)        smaller = (float)IMG_Y;    r_lugar = smaller/4.0*(M_PI/(M_PI+(float)rede->total_l));    if(buff == NULL)    {        printf("Could not create buffer!/n");        exit(EXIT_FAILURE);    }    /* Desenho propriamente dito */    if(rede->total_l > rede->total_t)        ang = M_PI/rede->total_l;    else        ang = M_PI/rede->total_t;    if(DEBUG == B || DEBUG == D) printf("Desenhando %u lugares e %u transicoes espacados entre si %.2f
C++ triangulate函数代码示例
C++ tri函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。