tomohiro-tabo

xyzrgb2yxzrgb_datachange.cpp

Jan 23rd, 2016
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<iomanip>
  4. #include<sstream>
  5.  
  6. using namespace std;
  7.  
  8. int main(int argc, char** argv)
  9. {
  10.  
  11. if(argc!=3)
  12. {
  13. fprintf(stderr,"Usage: %s\n(1)Input_filename\n(2)Output_filename",argv[0]);
  14. //exit(1);
  15. }
  16.  
  17. ifstream ifs(argv[1]);
  18. ofstream ofs(argv[2]);
  19. string line;
  20.  
  21. while(getline(ifs,line))
  22. {
  23. float x,y,z;
  24. //int a,b,c,d,e,f;
  25. int r,g,b;
  26. int x_i,y_i;
  27. float y_c,x_c;
  28. float r_f,g_f,b_f;
  29.  
  30. //std::cout << std::fixed << std::setprecision(2) << pi << '\n';
  31.  
  32. istringstream is(line);
  33.  
  34. is >> x >> y >> z >> r >> g >> b;
  35. r_f=(float)r/255;
  36. g_f=(float)r/255;
  37. b_f=(float)r/255;
  38.  
  39. //x_i=(int)x*10000;
  40. //y_i=(int)y*10000;
  41.  
  42. //y_c=(float)y_i/10000;
  43. //x_c=(float)x_i/10000;
  44.  
  45. //cout<< y <<" "<< x <<" "<< z <<" "<< r <<" "<< g <<" "<< b <<endl;
  46. ofs << fixed << setprecision(4) <<"glColor3f("<< r_f <<"f,"<< g_f<<"f,"<<b_f<<"f);glVertex3f("<<x<< "f," << y <<"f,"<< z<<"f);"<< endl;
  47.  
  48. }
  49. ifs.close();
  50. ofs.close();
  51.  
  52. return 0;
  53. }
Add Comment
Please, Sign In to add comment