当前位置: 首页>>代码示例>>C++>>正文


C++ red函数代码示例

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


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

示例1: show_chess

show_chess(int y, int x, char a, char b)
{
 char nn1[42][7]={
"★★★",
" ★★ ",
"  將  ",

"   �� ",
" 士�� ",
"   �� ",

"╭─╮",
"象 .│",
"  ╰ˋ",

"    車",
"╭Π╮",
"◎�龤�",

"馬  ▲",
"╭�灨�",
" ⊥⊥ ",

" △包 ",
" █   ",
"||||  ",

"  ●卒",
"╰�屣�",
" ╱╲ ",

"★★★",
" ★★ ",
"  帥  ",

"   �� ",
" 仕�� ",
"   �� ",

"╭─╮",
"相 .│",
"  ╰ˋ",

"    硨",
"╭Π╮",
"◎�龤�",

"傌  ▲",
"╭�灨�",
" ⊥⊥ ",

" △炮 ",
" █   ",
"||||  ",

"  ●兵",
"╰�屣�",
" ╱╲ "};

 y=y*24+20; 
 x=x*4+2;
 
 if(b) 
 {
   char p,i;
   p=(red(a)*7 + (a%64)/2-1)*3; 
   for(i=0; i<3; i++) printtt(x+i,y,"3%dm%s",red(a),nn1[i+p]);
 }
 else 
 {
   char *ptr;
   ptr = nn + red(a)*14 + a%64 - a%2;
   printtt(x  ,y,"3%dm%s", red(a), a?"╭─╮":"      ");
   printtt(x+1,y,"3%dm%s%c%c%s", 
      red(a), a?"│":"  ", *ptr, *(ptr+1), a?"│":"  ");
   printtt(x+2,y,"3%dm%s", red(a), a?"╰─╯":"      ");
 }
 refresh();
}
开发者ID:yrchen,项目名称:Athena,代码行数:79,代码来源:dark.c

示例2: glUseProgram

void Display::draw()
{
	std::vector<Particle*> particles = theFluid->getParticles();
	int w = camera->getWidth();
	int h = camera->getHeight();

	//BEGIN render from light
	glUseProgram(shadowShaderProgram);
	glBindFramebuffer(GL_FRAMEBUFFER, fbo);
	// Clear previous frame values
	glClear( GL_DEPTH_BUFFER_BIT);
	
	//Disable color rendering, we only want to write to the Z-Buffer
	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); 
	glCullFace( GL_FRONT );

	camera->setViewport(SHADOW_MAP_SIZE, SHADOW_MAP_SIZE);
	glViewport(0,0,SHADOW_MAP_SIZE,SHADOW_MAP_SIZE);
	vec3 pos = camera->getPos();
	camera->setPos( vec3( lightPos.x, lightPos.y, lightPos.z ) );
	
	mat4 cmat = camera->getMat4();
	
	glUniformMatrix4fv(u_shadowProjMatrixLocation, 1, GL_FALSE, &cmat[0][0]);

	if( pos.y > 0 ) 
		world->draw( shadowPositionLocation, colorLocation, normalLocation, u_shadowModelMatrixLocation );
	//TODO: draw particles
	World::Shape * particle = new World::Cube();
	for (unsigned int i = 0; i < particles.size(); i++)
	{
		int pidx = particles.at( i )->getIndex();
		if( flags & pidx )
		{
			particle->clearMat();
			particle->translate(particles.at(i)->getPosition()); 
			particle->scale( vec3( 0.04 ) );
			particle->draw( shadowPositionLocation, colorLocation, normalLocation, u_shadowModelMatrixLocation );
		}
	}
	//END render from light

	//BEGIN render from camera
	glUseProgram(shaderProgram);
	glBindFramebuffer(GL_FRAMEBUFFER, 0);
	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glUniform1i( u_shadowMapLocation, 7 );
	glActiveTexture(GL_TEXTURE7);
	glBindTexture(GL_TEXTURE_2D,depthTexture);

	float bias[16] = {	0.5, 0.0, 0.0, 0.0, 
						0.0, 0.5, 0.0, 0.0,
						0.0, 0.0, 0.5, 0.0,
						0.5, 0.5, 0.5, 1.0  };
	
	
	mat4 cameraMatrix = make_mat4( bias ) * cmat;
	glUniformMatrix4fv(u_shadowBiasMatrixLocation, 1, GL_FALSE, &cameraMatrix[0][0]);
	
	camera->setViewport(w, h);
	camera->setPos( pos );
	glViewport(0,0,w,h);
	glCullFace( GL_BACK );
	if( pos.y > 0 ) 
		world->draw( positionLocation, colorLocation, normalLocation, u_modelMatrixLocation );
	//TODO: draw particles
	vec3 red( 1,0,0 );
	vec3 blue( 0,0,1 );

	for (unsigned int i = 0; i < particles.size(); i++)
	{
		int pidx = particles.at( i )->getIndex();
		if( flags & pidx )
		{
			particle->clearMat();
			particle->translate(particles.at(i)->getPosition()); 
			particle->scale( vec3( 0.04 ) );

			if( flags & DFLAG_VEL )
			{
				particle->setColor( 0.1f+glm::clamp( particles.at(i)->getVelocity()*particles.at(i)->getVelocity()/5.0f, vec3(0.0), vec3(1.0) ) );
			}
			else if( flags & DFLAG_TEMP )
			{
				float alpha = ( particles.at( i )->getTemp() - 5 ) / 10;
				particle->setColor(alpha*red + (1-alpha)*blue);
			}
			else
			{
				particle->setColor( colorMap[pidx] );
			}
			particle->draw( positionLocation, colorLocation, normalLocation, u_modelMatrixLocation );
		}
	}	
	delete particle;
	
	//END render from camera
	glBindTexture(GL_TEXTURE_2D,0);
//.........这里部分代码省略.........
开发者ID:LingDu-san,项目名称:sph-2,代码行数:101,代码来源:display.cpp

示例3: Node

//----------------------------------------------------------------------------
void IntersectConvexPolyhedra::CreateScene ()
{
    mScene = new0 Node();
    mMotionObject = mScene;

    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT3, 0);
    int vstride = vformat->GetStride();

    // Attach a dummy intersection mesh.  If the intersection is nonempty,
    // the Culling flag will be modified to CULL_DYNAMIC.  The intersection
    // is drawn as a solid.
    mMeshIntersection = StandardMesh(vformat).Tetrahedron();
    VertexBufferAccessor vba(mMeshIntersection);
    Float3 green(0.0f, 1.0f, 0.0f);
    int i, j;
    for (i = 0; i < vba.GetNumVertices(); ++i)
    {
        vba.Color<Float3>(0, i) = green;
    }
    mMeshIntersection->SetEffectInstance(
        VertexColor3Effect::CreateUniqueInstance());
    mMeshIntersection->Culling = Spatial::CULL_ALWAYS;
    mScene->AttachChild(mMeshIntersection);

    // The first polyhedron is an ellipsoid.
    ConvexPolyhedronf::CreateEggShape(Vector3f::ZERO, 1.0f, 1.0f, 2.0f, 2.0f,
        4.0f, 4.0f, 3, mWorldPoly0);

    // Build the corresponding mesh.
    int numVertices = mWorldPoly0.GetNumVertices();
    int numTriangles = mWorldPoly0.GetNumTriangles();
    int numIndices = 3*numTriangles;
    VertexBuffer* vbuffer = new0 VertexBuffer(numVertices, vstride);
    IndexBuffer* ibuffer = new0 IndexBuffer(numIndices, sizeof(int));
    Float3 red(1.0f, 0.0f, 0.0f);
    vba.ApplyTo(vformat, vbuffer);
    for (i = 0; i < numVertices; ++i)
    {
        vba.Position<Vector3f>(i) = mWorldPoly0.Point(i);
        vba.Color<Float3>(0,i) = red;
    }
    int* indices = (int*)ibuffer->GetData();
    for (i = 0; i < numTriangles; ++i)
    {
        const MTTriangle& triangle = mWorldPoly0.GetTriangle(i);
        for (j = 0; j < 3; ++j)
        {
            indices[3*i + j] = mWorldPoly0.GetVLabel(triangle.GetVertex(j));
        }
    }

    mMeshPoly0 = new0 TriMesh(vformat, vbuffer, ibuffer);
    VisualEffectInstance* instance =
        VertexColor3Effect::CreateUniqueInstance();
    instance->GetEffect()->GetWireState(0, 0)->Enabled = true;
    mMeshPoly0->SetEffectInstance(instance);
    mMeshPoly0->LocalTransform.SetTranslate(APoint(0.0f, 2.0f, 0.0f));
    mScene->AttachChild(mMeshPoly0);

    // The second polyhedron is egg shaped.
    ConvexPolyhedronf::CreateEggShape(Vector3f::ZERO, 2.0f, 2.0f, 4.0f, 4.0f,
        5.0f, 3.0f, 4, mWorldPoly1);

    // Build the corresponding mesh.
    numVertices = mWorldPoly1.GetNumVertices();
    numTriangles = mWorldPoly1.GetNumTriangles();
    numIndices = 3*numTriangles;
    vbuffer = new0 VertexBuffer(numVertices, vstride);
    ibuffer = new0 IndexBuffer(numIndices, sizeof(int));
    Float3 blue(0.0f, 0.0f, 1.0f);
    vba.ApplyTo(vformat, vbuffer);
    for (i = 0; i < numVertices; ++i)
    {
        vba.Position<Vector3f>(i) = mWorldPoly1.Point(i);
        vba.Color<Float3>(0, i) = blue;
    }
    indices = (int*)ibuffer->GetData();
    for (i = 0; i < numTriangles; ++i)
    {
        const MTTriangle& triangle = mWorldPoly1.GetTriangle(i);
        for (j = 0; j < 3; ++j)
        {
            indices[3*i + j] = mWorldPoly1.GetVLabel(triangle.GetVertex(j));
        }
    }

    mMeshPoly1 = new0 TriMesh(vformat, vbuffer, ibuffer);
    instance = VertexColor3Effect::CreateUniqueInstance();
    instance->GetEffect()->GetWireState(0, 0)->Enabled = true;
    mMeshPoly1->SetEffectInstance(instance);
    mMeshPoly1->LocalTransform.SetTranslate(APoint(0.0f, -2.0f, 0.0f));
    mScene->AttachChild(mMeshPoly1);

    ComputeIntersection();
}
开发者ID:rasslingcats,项目名称:calico,代码行数:98,代码来源:IntersectConvexPolyhedra.cpp

示例4: main

int 
main (int argc, char ** argv)
{
  if (argc < 3) 
  {
    pcl::console::print_info ("Syntax is: %s source target <options>\n", argv[0]);
    pcl::console::print_info ("  where options are:\n");
    pcl::console::print_info ("    -i min_sample_dist,max_dist,nr_iters ................ Compute initial alignment\n");
    pcl::console::print_info ("    -r max_dist,rejection_thresh,tform_eps,max_iters ............. Refine alignment\n");
    pcl::console::print_info ("    -s output.pcd ........................... Save the registered and merged clouds\n");
    pcl::console::print_info ("Note: The inputs (source and target) must be specified without the .pcd extension\n");

    return (1);
  }

  // Load the points
  PointCloudPtr src_points = loadPoints (argv[1]);
  PointCloudPtr tgt_points = loadPoints (argv[2]);
  Eigen::Matrix4f tform = Eigen::Matrix4f::Identity ();

  // Compute the intial alignment
  double min_sample_dist, max_correspondence_dist, nr_iters;
  bool compute_intial_alignment = 
    pcl::console::parse_3x_arguments (argc, argv, "-i", min_sample_dist, max_correspondence_dist, nr_iters) > 0;
  if (compute_intial_alignment)
  {
    // Load the keypoints and local descriptors
    PointCloudPtr src_keypoints = loadKeypoints (argv[1]);
    LocalDescriptorsPtr src_descriptors = loadLocalDescriptors (argv[1]);
    PointCloudPtr tgt_keypoints = loadKeypoints (argv[2]);
    LocalDescriptorsPtr tgt_descriptors = loadLocalDescriptors (argv[2]);

    // Find the transform that roughly aligns the points
    tform = computeInitialAlignment (src_keypoints, src_descriptors, tgt_keypoints, tgt_descriptors,
                                     min_sample_dist, max_correspondence_dist, nr_iters);
    
    pcl::console::print_info ("Computed initial alignment\n");
  }

  // Refine the initial alignment
  std::string params_string;
  bool refine_alignment = pcl::console::parse_argument (argc, argv, "-r", params_string) > 0;
  if (refine_alignment)
  {
    std::vector<std::string> tokens;
    boost::split (tokens, params_string, boost::is_any_of (","), boost::token_compress_on);
    assert (tokens.size () == 4);    
    float max_correspondence_distance = atof(tokens[0].c_str ());
    float outlier_rejection_threshold = atof(tokens[1].c_str ());
    float transformation_epsilon = atoi(tokens[2].c_str ());
    int max_iterations = atoi(tokens[3].c_str ());

    tform = refineAlignment (src_points, tgt_points, tform, max_correspondence_distance,  
                             outlier_rejection_threshold, transformation_epsilon, max_iterations);

    pcl::console::print_info ("Refined alignment\n");
  }  

  // Transform the source point to align them with the target points
  pcl::transformPointCloud (*src_points, *src_points, tform);

  // Save output
  std::string filename;
  bool save_output = pcl::console::parse_argument (argc, argv, "-s", filename) > 0;
  if (save_output)
  {
    // Merge the two clouds
    (*src_points) += (*tgt_points);

    // Save the result
    pcl::io::savePCDFile (filename, *src_points);

    pcl::console::print_info ("Saved registered clouds as %s\n", filename.c_str ());    
  }
  // Or visualize the result
  else
  {
    pcl::console::print_info ("Starting visualizer... Close window to exit\n");
    pcl::visualization::PCLVisualizer vis;

    pcl::visualization::PointCloudColorHandlerCustom<PointT> red (src_points, 255, 0, 0);
    vis.addPointCloud (src_points, red, "src_points");

    pcl::visualization::PointCloudColorHandlerCustom<PointT> yellow (tgt_points, 255, 255, 0);
    vis.addPointCloud (tgt_points, yellow, "tgt_points");
    
    vis.resetCamera ();
    vis.spin ();
  }

  return (0);
}
开发者ID:hitsjt,项目名称:StanfordPCL,代码行数:92,代码来源:test_registration.cpp

示例5: place_item

int 
place_item (int x, int y, short type)
{
    int group;
    int size;

    group = get_group_of_type(type);
    if (group < 0) return -1;

    size = main_groups[group].size;

    /* You can't build because credit not available. */
    if (no_credit_build (group) != 0) {
	return -1;
    }

    /* Not enough slots in the substation array */

    switch (group) {
    case GROUP_SUBSTATION:
    case GROUP_WINDMILL:
    {
	if (add_a_substation (x, y) == 0)
	    return -3;
    } break;
    case GROUP_PORT:
    {
	if (is_real_river (x + 4, y) != 1 
	    || is_real_river (x + 4, y + 1) != 1
	    || is_real_river (x + 4, y + 2) != 1 
	    || is_real_river (x + 4, y + 3) != 1) {
	    return -2;
	}
    } break;
    case GROUP_COMMUNE:
    {
	numof_communes++;
    } break;
    case GROUP_MARKET:
    {
	/* Test for enough slots in the market array */
	if (add_a_market (x, y) == 0)
	    return -3;
	MP_INFO(x,y).flags += (FLAG_MB_FOOD | FLAG_MB_JOBS
			       | FLAG_MB_COAL | FLAG_MB_ORE | FLAG_MB_STEEL
			       | FLAG_MB_GOODS | FLAG_MS_FOOD | FLAG_MS_JOBS
			       | FLAG_MS_COAL | FLAG_MS_GOODS | FLAG_MS_ORE
			       | FLAG_MS_STEEL);
    } break;
    case GROUP_TIP:
    {
	/* Don't build a tip if there has already been one.  If we succeed,
	   mark the spot permanently by "doubling" the ore reserve */
	int i,j;
	int prev_tip = 0;
	for (i=0;i<3;i++) {
	    for (j=0;j<3;j++) {
		if (MP_INFO(x+i,y+j).ore_reserve > ORE_RESERVE) {
		    prev_tip = 1;
		    break;
		}
	    }
	}
	if (prev_tip) {
	    dialog_box(red(12),3,
		       0,0,_("You can't build a tip here"),
		       0,0,_("This area was once a landfill"),
		       2,' ',_("OK"));
	    return -4;
	} else {
	    for (i=0;i<3;i++) {
		for (j=0;j<3;j++) {
		    MP_INFO(x+i,y+j).ore_reserve = ORE_RESERVE * 2;
		}
	    }
	}
    } break;
    case GROUP_OREMINE:
    {
	/* Don't allow new mines on old mines or old tips */
	/* GCS: mines over old mines is OK if there is enough remaining 
	        ore, as is the case when there is partial overlap. */
	int i,j;
	int prev_tip = 0;
	int total_ore = 0;
	for (i=0;i<3;i++) {
	    for (j=0;j<3;j++) {
		total_ore += MP_INFO(x+i,y+j).ore_reserve;
		if (MP_INFO(x+i,y+j).ore_reserve > ORE_RESERVE) {
		    prev_tip = 1;
		    break;
		}
	    }
	}
	if (prev_tip) {
	    dialog_box(red(12),3,
		       0,0,_("You can't build a mine here"),
		       0,0,_("This area was once a landfill"),
		       2,' ',_("OK"));
	    return -4;
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:lincity-ng-svn,代码行数:101,代码来源:engine.c

示例6: main

int main(int argc, char **argv)
{
  cout << "Starting" << endl;
  double point[2];
  double * current = new double[9];
  double * best = new double[9];
  double * init = new double[9];
  double ncc;
  double bestncc = -2;
  double first;
  double scale = 1;
  //int position = 0;
  //int direction = 1;
  bool optimize = true;

 cout << "Starting" << endl; 
 vector<PixelLoc> interior;
 for(int i=9; i<=23; ++i){
  for(int j=9; j<=23; ++j){
  PixelLoc point(i, j);
  interior.push_back(point);
  }
 }
cout << "Creating Images";
 Image myimg("test-initial.ppm");
 Image myimgOther("test-final.ppm");
cout << "Images created";
 for(int i=0;i<9;++i){
    init[i] = current[i] = best[i] = 0; 
 }
    init[8] = current[8] = best[8] = 1;
    init[0] = current[0] = best[0] = 1;
    init[4] = current[4] = best[4] = 1;

  cout << "initial homography: " << endl;
  for (int i = 0; i < 9; i++){
    cout << init[i] << " ";
  }

Color red(255,0,0);
Color blue(0,0,100);

Image imgInitial = myimg;
Image src = myimgOther;

for(unsigned int i=0; i<interior.size(); ++i){
   homography(interior[i].x, interior[i].y, current, point);
   PixelLoc loc((int)point[0], (int)point[1]);
   if(inImage(&imgInitial,loc)){
       imgInitial.setPixel(loc,blue);
   }
}

imgInitial.print("initial.ppm");

for(unsigned int i=0; i<interior.size(); ++i){
   if(inImage(&src,interior[i])){
      src.setPixel(interior[i],blue);
   }
}
src.print("src.ppm");

cout << endl;

if(optimize){
  Optimize (scale, first, ncc, bestncc, &interior, init, current, best, &myimg, &myimgOther);
}
 
 cout << "First: " << first << " Best: " << bestncc << endl;
 cout << "homography: "; 
 for(int i=0;i<9;++i){
  cout << current[i] << " ";
 } 
 cout << endl;
Image imgFinal = myimg;

printHomographyTile(&imgFinal,&imgInitial,interior,best);
system("/home/mscs/bin/show src.ppm initial.ppm final.ppm");
}
开发者ID:piersonv,项目名称:CS_Capstone,代码行数:79,代码来源:optimize-test_CUDA.cpp

示例7: btAdjustInternalEdgeContacts

/// Changes a btManifoldPoint collision normal to the normal from the mesh.
void btAdjustInternalEdgeContacts(btManifoldPoint& cp, const btCollisionObject* colObj0,const btCollisionObject* colObj1, int partId0, int index0, int normalAdjustFlags)
{
	//btAssert(colObj0->getCollisionShape()->getShapeType() == TRIANGLE_SHAPE_PROXYTYPE);
	if (colObj0->getCollisionShape()->getShapeType() != TRIANGLE_SHAPE_PROXYTYPE)
		return;

	btBvhTriangleMeshShape* trimesh = (btBvhTriangleMeshShape*)colObj0->getRootCollisionShape();
	btTriangleInfoMap* triangleInfoMapPtr = (btTriangleInfoMap*) trimesh->getTriangleInfoMap();
	if (!triangleInfoMapPtr)
		return;

	int hash = btGetHash(partId0,index0);


	btTriangleInfo* info = triangleInfoMapPtr->find(hash);
	if (!info)
		return;

	btScalar frontFacing = (normalAdjustFlags & BT_TRIANGLE_CONVEX_BACKFACE_MODE)==0? 1.f : -1.f;
	
	const btTriangleShape* tri_shape = static_cast<const btTriangleShape*>(colObj0->getCollisionShape());
	btVector3 v0,v1,v2;
	tri_shape->getVertex(0,v0);
	tri_shape->getVertex(1,v1);
	tri_shape->getVertex(2,v2);

	btVector3 center = (v0+v1+v2)*btScalar(1./3.);

	btVector3 red(1,0,0), green(0,1,0),blue(0,0,1),white(1,1,1),black(0,0,0);
	btVector3 tri_normal;
	tri_shape->calcNormal(tri_normal);

	//btScalar dot = tri_normal.dot(cp.m_normalWorldOnB);
	btVector3 nearest;
	btNearestPointInLineSegment(cp.m_localPointB,v0,v1,nearest);

	btVector3 contact = cp.m_localPointB;
#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
	const btTransform& tr = colObj0->getWorldTransform();
	btDebugDrawLine(tr*nearest,tr*cp.m_localPointB,red);
#endif //BT_INTERNAL_EDGE_DEBUG_DRAW



	bool isNearEdge = false;

	int numConcaveEdgeHits = 0;
	int numConvexEdgeHits = 0;

	btVector3 localContactNormalOnB = colObj0->getWorldTransform().getBasis().transpose() * cp.m_normalWorldOnB;
	localContactNormalOnB.normalize();//is this necessary?

	if ((info->m_edgeV0V1Angle)< SIMD_2_PI)
	{
#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
		btDebugDrawLine(tr*contact,tr*(contact+cp.m_normalWorldOnB*10),black);
#endif
		btScalar len = (contact-nearest).length();
		if(len<triangleInfoMapPtr->m_edgeDistanceThreshold)
		{
			btVector3 edge(v0-v1);
			isNearEdge = true;

			if (info->m_edgeV0V1Angle==btScalar(0))
			{
				numConcaveEdgeHits++;
			} else
			{

				bool isEdgeConvex = (info->m_flags & TRI_INFO_V0V1_CONVEX);
				btScalar swapFactor = isEdgeConvex ? btScalar(1) : btScalar(-1);
	#ifdef BT_INTERNAL_EDGE_DEBUG_DRAW
				btDebugDrawLine(tr*nearest,tr*(nearest+swapFactor*tri_normal*10),white);
	#endif //BT_INTERNAL_EDGE_DEBUG_DRAW

				btVector3 nA = swapFactor * tri_normal;

				btQuaternion orn(edge,info->m_edgeV0V1Angle);
				btVector3 computedNormalB = quatRotate(orn,tri_normal);
				if (info->m_flags & TRI_INFO_V0V1_SWAP_NORMALB)
					computedNormalB*=-1;
				btVector3 nB = swapFactor*computedNormalB;

				btScalar	NdotA = localContactNormalOnB.dot(nA);
				btScalar	NdotB = localContactNormalOnB.dot(nB);
				bool backFacingNormal = (NdotA< triangleInfoMapPtr->m_convexEpsilon) && (NdotB<triangleInfoMapPtr->m_convexEpsilon);

#ifdef DEBUG_INTERNAL_EDGE
				{
					
					btDebugDrawLine(cp.getPositionWorldOnB(),cp.getPositionWorldOnB()+tr.getBasis()*(nB*20),red);
				}
#endif //DEBUG_INTERNAL_EDGE


				if (backFacingNormal)
				{
					numConcaveEdgeHits++;
				}
//.........这里部分代码省略.........
开发者ID:Amplifying,项目名称:intensityengine,代码行数:101,代码来源:btInternalEdgeUtility.cpp

示例8: main

int main(int argc, char* argv[]) {
  // compiler will whine about it being deprecated, but taking it out
  // blows things up
  // used for GIO
  g_type_init();
  g_log_set_always_fatal(G_LOG_LEVEL_ERROR);
  g_log_set_handler(G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG |
                    G_LOG_LEVEL_ERROR |
                    G_LOG_LEVEL_WARNING |
                    G_LOG_LEVEL_MESSAGE |
                    G_LOG_FLAG_RECURSION |
                    G_LOG_FLAG_FATAL,  erln8_log, NULL);
  homedir = g_getenv("ERLN8_HOME");
  if(homedir == NULL) {
    homedir = g_get_home_dir();
  } else {
    // builds will fail if ERLN8_HOME is not an absolute path
    if(homedir[0] != '/') {
      g_error("ERLN8_HOME must be an absolute path\n");
    }
  }
  g_debug("home directory = %s\n", homedir);
  gchar* basename = g_path_get_basename(argv[0]);
  g_debug("basename = %s\n", basename);
  if((!strcmp(basename, "erln8")) || (!strcmp(basename, "./erln8"))) {
    erln8(argc, argv);
    g_free(basename);
  } else {
    gchar* erl = which_erlang();
    if(erl == NULL) {
      g_message("Can't find an " ERLN8_CONFIG_FILE " file to use\n");
      g_error("No " ERLN8_CONFIG_FILE " file\n");
    }
    GHashTable* erlangs = get_erlangs();
    GHashTable* runtime_options = get_erln8();
    gchar* path = g_hash_table_lookup(erlangs, erl);
    if(path == NULL) {
      g_hash_table_destroy(erlangs);
      g_hash_table_destroy(runtime_options);
      g_error("Version of Erlang (%s) isn't configured in erln8\n",
              erl);
    }
    gchar* use_color = (gchar*)g_hash_table_lookup(runtime_options, "color");
    if(g_strcmp0(use_color, "true") == 0) {
      opt_color = TRUE;
    } else {
      opt_color = FALSE;
    }
    gchar* use_banner = (gchar*)g_hash_table_lookup(runtime_options, "banner");
    if(g_strcmp0(use_banner, "true") == 0) {
      opt_banner = TRUE;
    } else {
      opt_banner = FALSE;
    }
    gchar* s = get_bin(erl, basename);
    g_debug("%s\n",s);
    gboolean result = g_file_test(s,
                                  G_FILE_TEST_EXISTS |
                                  G_FILE_TEST_IS_REGULAR);
    g_free(basename);
    if(!result) {
      g_hash_table_destroy(erlangs);
      g_hash_table_destroy(runtime_options);
      g_free(s);
      g_error("Can't run %s, check to see if the file exists\n", s);
    }
    if(opt_banner) {
      printf("%s", red());
      printf("erln8: %s", blue());
      printf("using Erlang %s", path);
      printf("%s\n", color_reset());
    }
    g_hash_table_destroy(erlangs);
    g_hash_table_destroy(runtime_options);
    // can't free s
    execv(s, argv);
  }
  return 0;
}
开发者ID:mkb,项目名称:erln8,代码行数:79,代码来源:erln8.c

示例9: Node

//----------------------------------------------------------------------------
Node* RoughPlaneSolidBox::CreateBox ()
{
    mBox = new0 Node();

    float xExtent = (float)mModule.XLocExt;
    float yExtent = (float)mModule.YLocExt;
    float zExtent = (float)mModule.ZLocExt;

    VertexFormat* vformat = VertexFormat::Create(2,
        VertexFormat::AU_POSITION, VertexFormat::AT_FLOAT3, 0,
        VertexFormat::AU_COLOR, VertexFormat::AT_FLOAT3, 0);

    StandardMesh sm(vformat);
    VertexColor3Effect* effect = new0 VertexColor3Effect();
    VertexBufferAccessor vba;
    Transform transform;
    TriMesh* face;
    int i;

    // +z face
    Float3 red(1.0f, 0.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, 0.0f, zExtent));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, xExtent, yExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = red;
        vba.Color<Float3>(0, 1) = red;
        vba.Color<Float3>(0, 2) = red;
        vba.Color<Float3>(0, 3) = red;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // -z face
    Float3 darkRed(0.5f, 0.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, 0.0f, -zExtent));
    transform.SetRotate(HMatrix(AVector::UNIT_Y, AVector::UNIT_X,
        -AVector::UNIT_Z, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, yExtent, xExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = darkRed;
        vba.Color<Float3>(0, 1) = darkRed;
        vba.Color<Float3>(0, 2) = darkRed;
        vba.Color<Float3>(0, 3) = darkRed;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // +y face
    Float3 green(0.0f, 1.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, yExtent, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_Z, AVector::UNIT_X,
        AVector::UNIT_Y, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, zExtent, xExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = green;
        vba.Color<Float3>(0, 1) = green;
        vba.Color<Float3>(0, 2) = green;
        vba.Color<Float3>(0, 3) = green;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // -y face
    Float3 darkGreen(0.0f, 1.0f, 0.0f);
    transform.SetTranslate(APoint(0.0f, -yExtent, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_X, AVector::UNIT_Z,
        -AVector::UNIT_Y, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, xExtent, zExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
        vba.Color<Float3>(0, 0) = darkGreen;
        vba.Color<Float3>(0, 1) = darkGreen;
        vba.Color<Float3>(0, 2) = darkGreen;
        vba.Color<Float3>(0, 3) = darkGreen;
    }
    face->SetEffectInstance(effect->CreateInstance());
    mBox->AttachChild(face);

    // +x face
    Float3 blue(0.0f, 0.0f, 1.0f);
    transform.SetTranslate(APoint(xExtent, 0.0f, 0.0f));
    transform.SetRotate(HMatrix(AVector::UNIT_Y, AVector::UNIT_Z,
        AVector::UNIT_X, APoint::ORIGIN, true));
    sm.SetTransform(transform);
    face = sm.Rectangle(2, 2, yExtent, zExtent);
    vba.ApplyTo(face);
    for (i = 0; i < 4; ++i)
    {
//.........这里部分代码省略.........
开发者ID:2asoft,项目名称:GeometricTools,代码行数:101,代码来源:RoughPlaneSolidBox.cpp

示例10: qRed

inline quint8 qRed( Colour16 _colour16 ) {
    return red(_colour16) * 8;
}
开发者ID:greeduomacro,项目名称:nordwind,代码行数:3,代码来源:Typedefs.hpp

示例11: printf

void Viewer::display()
{
    int changedIndex;
    openni::Status rc = openni::OpenNI::waitForAnyStream(m_stream, 2, &changedIndex);
    if (rc != openni::STATUS_OK)
    {
        printf("Wait failed\n");
        return;
    }

    if (changedIndex == 0 && !first)
    {
        m_depth.readFrame(&m_depthFrame);

        glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
        glMatrixMode(GL_MODELVIEW);
        glPushMatrix();
        glLoadIdentity();

        gluLookAt(cx, 1.0f, cz,
                  cx + lx, 1.0f, cz + lz,
                  0.0f, 1.0f,  0.0f);

        memset(m_inPlane, false, m_width * m_height * sizeof(bool));

        const openni::DepthPixel* pDepthRow = (const openni::DepthPixel*)m_depthFrame.getData();
        int rowSize = m_depthFrame.getStrideInBytes() / sizeof(openni::DepthPixel);
        int cnt = 0;
        for (int y = 0; y < m_depthFrame.getHeight(); y += 2)
        {
            const openni::DepthPixel* pDepth = pDepthRow;

            for (int x = 0; x < m_depthFrame.getWidth(); x += 2, pDepth += 2)
            {
                if (*pDepth != 0)
                {
                    float wx, wy, wz;
                    openni::CoordinateConverter::convertDepthToWorld(m_depth, x, y, *pDepth, &wx, &wy, &wz);
                    //depthToWorld(x, y, *pDepth, &wx, &wy, &wz);
                    m_pointCloud[cnt][0] = wx;
                    m_pointCloud[cnt][1] = wy;
                    m_pointCloud[cnt][2] = wz;
                    m_pixelToCloud[y * m_width + x] = cnt;
                    cnt++;
                }
                else
                    m_pixelToCloud[y * m_width + x] = -1;
            }

            pDepthRow += rowSize * 2;
        }

        float intersect;
        float normalX, normalY, normalZ, d;
        m_ransac->MarkPointsInBestFitPlane(m_pointCloud, cnt, m_inPlane, &normalX, &normalY, &normalZ, &d, &intersect);

        pDepthRow = (const openni::DepthPixel*)m_depthFrame.getData();
        rowSize = m_depthFrame.getStrideInBytes() / sizeof(openni::DepthPixel);

        for (int y = 0; y < m_depthFrame.getHeight(); y += 2)
        {
            for (int x = 0; x < m_depthFrame.getWidth(); x += 2)
            {
                m_binaryImage[y / 2][x / 2] = m_pixelToCloud[y * m_width + x] != -1 ? !m_inPlane[m_pixelToCloud[y * m_width + x]] : false;
            }
        }

        int blobs = m_blobExtractor->ExtractBlobs(m_binaryImage, m_blobs);
        vector<float*> blobPoints[blobs];
        vector<openni::RGB888Pixel> blobColors[blobs];
        for (int y = 0; y < m_depthFrame.getHeight(); y += 2)
        {
            for (int x = 0; x < m_depthFrame.getWidth(); x += 2)
            {
                if (m_pixelToCloud[y * m_width + x] != -1)
                {
                    int i = m_pixelToCloud[y * m_width + x];
                    if (m_blobs[y / 2][x / 2] == 0)
                    {
                    }
                    else
                    {
                        openni::RGB888Pixel pixel = m_colorData[y * m_width + x];
                        blobColors[m_blobs[y / 2][x / 2] - 1].push_back(pixel);
                        glColor3f(pixel.r / 255.0, pixel.g / 255.0, pixel.b / 255.0);
                        glBegin(GL_POINTS);
                        glVertex3f(m_pointCloud[i][0], m_pointCloud[i][1], -m_pointCloud[i][2]);
                        glEnd();
                        blobPoints[m_blobs[y / 2][x / 2] - 1].push_back(m_pointCloud[i]);
                    }
                }
            }
        }
        float maxPercentRed = -1;
        float maxPercentBlue = -1;
        int blueBlob;
        int redBlob;
        for (int i = 0; i < blobs; i++)
        {
            int numBlue = 0, numRed = 0;
//.........这里部分代码省略.........
开发者ID:raphaelchang,项目名称:balltracking,代码行数:101,代码来源:Viewer.cpp

示例12: green

const PPM_Color PPM_Image::color(const int x, const int y) const {
    const uint c {vals_[x][y]};
    return PPM_Color {red(c), green(c), blue(c)};
}
开发者ID:Tigrolik,项目名称:Computer_graphics,代码行数:4,代码来源:PPM_Image.cpp

示例13: glPushName

void
GUIParkingArea::drawGL(const GUIVisualizationSettings& s) const {
    glPushName(getGlID());
    glPushMatrix();
    RGBColor grey(177, 184, 186, 171);
    RGBColor blue(83, 89, 172, 255);
    RGBColor red(255, 0, 0, 255);
    RGBColor green(0, 255, 0, 255);
    // draw the area
    glTranslated(0, 0, getType());
    GLHelper::setColor(blue);
    GLHelper::drawBoxLines(myShape, myShapeRotations, myShapeLengths, myWidth / 2.);
    // draw details unless zoomed out to far
    const SUMOReal exaggeration = s.addSize.getExaggeration(s);
    if (s.scale * exaggeration >= 10) {
        // draw the lots
        glTranslated(0, 0, .1);
        std::map<unsigned int, LotSpaceDefinition >::const_iterator i;
        for (i = mySpaceOccupancies.begin(); i != mySpaceOccupancies.end(); i++) {
            glPushMatrix();
            glTranslated((*i).second.myPosition.x(), (*i).second.myPosition.y(), (*i).second.myPosition.z());
            glRotated((*i).second.myRotation, 0, 0, 1);
            Position pos = (*i).second.myPosition;
            PositionVector geom;
            SUMOReal w = (*i).second.myWidth / 2.;
            SUMOReal h = (*i).second.myLength;
            geom.push_back(Position(- w, + 0, 0.));
            geom.push_back(Position(+ w, + 0, 0.));
            geom.push_back(Position(+ w, + h, 0.));
            geom.push_back(Position(- w, + h, 0.));
            geom.push_back(Position(- w, + 0, 0.));
            /*
            geom.push_back(Position(pos.x(), pos.y(), pos.z()));
            geom.push_back(Position(pos.x() + (*l).second.myWidth, pos.y(), pos.z()));
            geom.push_back(Position(pos.x() + (*l).second.myWidth, pos.y() - (*l).second.myLength, pos.z()));
            geom.push_back(Position(pos.x(), pos.y() - (*l).second.myLength, pos.z()));
            geom.push_back(Position(pos.x(), pos.y(), pos.z()));
            */
            GLHelper::setColor((*i).second.vehicle == 0 ? green : red);
            GLHelper::drawBoxLines(geom, 0.1);
            glPopMatrix();
        }
        GLHelper::setColor(blue);
        // draw the lines
        for (size_t i = 0; i != myLines.size(); ++i) {
            glPushMatrix();
            glTranslated(mySignPos.x(), mySignPos.y(), 0);
            glRotated(180, 1, 0, 0);
            glRotated(mySignRot, 0, 0, 1);
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
            pfSetPosition(0, 0);
            pfSetScale(1.f);
            glScaled(exaggeration, exaggeration, 1);
            glTranslated(1.2, -(double)i, 0);
            pfDrawString(myLines[i].c_str());
            glPopMatrix();
        }
        // draw the sign
        glTranslated(mySignPos.x(), mySignPos.y(), 0);
        int noPoints = 9;
        if (s.scale * exaggeration > 25) {
            noPoints = MIN2((int)(9.0 + (s.scale * exaggeration) / 10.0), 36);
        }
        glScaled(exaggeration, exaggeration, 1);
        GLHelper::drawFilledCircle((SUMOReal) 1.1, noPoints);
        glTranslated(0, 0, .1);
        GLHelper::setColor(grey);
        GLHelper::drawFilledCircle((SUMOReal) 0.9, noPoints);
        if (s.scale * exaggeration >= 4.5) {
            GLHelper::drawText("P", Position(), .1, 1.6 * exaggeration, blue, mySignRot);
        }
    }
    glPopMatrix();
    glPopName();
    drawName(getCenteringBoundary().getCenter(), s.scale, s.addName);
    for (std::vector<MSTransportable*>::const_iterator i = myWaitingTransportables.begin(); i != myWaitingTransportables.end(); ++i) {
        glTranslated(0, 1, 0); // make multiple containers viewable
        static_cast<GUIContainer*>(*i)->drawGL(s);
    }
}
开发者ID:planetsumo,项目名称:sumo,代码行数:80,代码来源:GUIParkingArea.cpp

示例14: to_string

 inline std::string to_string() const
 {
     std::stringstream ss;
     ss << "rgb (" << red() << ","  << green() << ","  << blue() <<")";
     return ss.str();
 }
开发者ID:BackupTheBerlios,项目名称:mapnik-svn,代码行数:6,代码来源:color.hpp

示例15: x

std::vector<Dimension> MrsidReader::getDefaultDimensions()
{
    std::vector<Dimension> output;

    Dimension x("X", dimension::Float, 8);
    x.setUUID("8c54ff0c-234f-43a2-8959-d9681ad1dea3");
    x.setNamespace(s_getName());
    output.push_back(x);

    Dimension y("Y", dimension::Float, 8);
    y.setUUID("9cee971b-2505-40cd-b7e9-f32c399afac7");
    y.setNamespace(s_getName());
    output.push_back(y);

    Dimension z("Z", dimension::Float, 8);
    z.setUUID("89dc4e36-6166-4bc8-bf95-5660657b0ea6");
    z.setNamespace(s_getName());
    output.push_back(z);

    Dimension t("Time", dimension::Float, 8);
    t.setUUID("3aea2826-4a6e-4c1b-ae27-7b2f24763ce1");
    t.setNamespace(s_getName());
    output.push_back(t);

    Dimension blue("Blue", dimension::UnsignedInteger, 2);
    blue.setUUID("f69977e3-23e8-4483-91b6-14cad981e9fd");
    blue.setNamespace(s_getName());
    output.push_back(blue);

    Dimension red("Red", dimension::UnsignedInteger, 2);
    red.setUUID("40a02a80-c399-42f0-a587-a286635b446e");
    red.setNamespace(s_getName());
    output.push_back(red);

    Dimension green("Green", dimension::UnsignedInteger, 2);
    green.setUUID("b329df2d-44f1-4f35-8993-d183dacaa1ff");
    green.setNamespace(s_getName());
    output.push_back(green);

    Dimension cls("Classification", dimension::UnsignedInteger, 1);
    cls.setUUID("ba1e2af8-6dfd-46a7-972a-ecc00f68914d");
    cls.setNamespace(s_getName());
    output.push_back(cls);

    Dimension edge("EdgeOfFlightLine", dimension::UnsignedInteger, 1);
    edge.setUUID("daed3bfc-650d-4265-93a7-d8093cbd75a0");
    edge.setNamespace(s_getName());
    output.push_back(edge);

    Dimension intensity("Intensity", dimension::UnsignedInteger, 2);
    intensity.setUUID("a43332a8-26b3-4609-a2b1-ddfda30e0565");
    intensity.setNamespace(s_getName());
    output.push_back(intensity);

    Dimension num_returns("NumberOfReturns", dimension::UnsignedInteger, 1);
    num_returns.setUUID("fa7c5d56-fb2b-4f81-9126-f183000c3cd8");
    num_returns.setNamespace(s_getName());
    output.push_back(num_returns);

    Dimension return_no("ReturnNumber", dimension::UnsignedInteger, 1);
    return_no.setUUID("e38cc121-8d26-482a-8920-c5599b2cdd19");
    return_no.setNamespace(s_getName());
    output.push_back(return_no);

    Dimension scan_angle("ScanAngleRank", dimension::UnsignedInteger, 1);
    scan_angle.setUUID("5d816875-10a5-4048-ad9d-fd3b8d065a6a");
    scan_angle.setNamespace(s_getName());
    output.push_back(scan_angle);

    Dimension scan_dir("ScanDirectionFlag", dimension::UnsignedInteger, 1);
    scan_dir.setUUID("d1054379-8bf6-4685-abfc-1f0ec37aa819");
    scan_dir.setNamespace(s_getName());
    output.push_back(scan_dir);

    Dimension ptsource("PointSourceId", dimension::UnsignedInteger, 2);
    ptsource.setUUID("be6e71af-b2f7-4107-a902-96e2fb71343f");
    ptsource.setNamespace(s_getName());
    output.push_back(ptsource);

    Dimension userdata("UserData", dimension::UnsignedInteger, 1);
    userdata.setUUID("551ca4be-cb6e-47a4-93a9-e403e9a06a8a");
    userdata.setNamespace(s_getName());
    output.push_back(userdata);

    return output;
}
开发者ID:adam-erickson,项目名称:PDAL,代码行数:86,代码来源:MrsidReader.cpp


注:本文中的red函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。