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[ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/tools/sg/mnmx (Version 11.3.0) and /externals/g4tools/include/tools/sg/mnmx (Version 10.0.p3)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef tools_sg_mnmx                             
  5 #define tools_sg_mnmx                             
  6                                                   
  7 #include "node"                                   
  8 #include "bbox_action"                            
  9                                                   
 10 namespace tools {                                 
 11                                                   
 12 inline bool mnmx(std::ostream& a_out,sg::node&    
 13   sg::bbox_action action(a_out);                  
 14   a_node.bbox(action);                            
 15   if(!action.end() || action.box().is_empty())    
 16     a_out << "tools::mnmx :"                      
 17           << " bbox problem."                     
 18           << std::endl;                           
 19     a_mn.set_value(0,0,0);                        
 20     a_mx.set_value(0,0,0);                        
 21     return false;                                 
 22   }                                               
 23   a_mn = action.box().mn();                       
 24   a_mx = action.box().mx();                       
 25   return true;                                    
 26 }                                                 
 27                                                   
 28 }                                                 
 29                                                   
 30 #include "matrix"                                 
 31                                                   
 32 namespace tools {                                 
 33                                                   
 34 inline bool center_adjust(std::ostream& a_out,    
 35                           sg::node& a_node,sg:    
 36                           unsigned int a_ww,un    
 37                           float a_height,         
 38                           float& a_dx,float& a    
 39                           bool a_verbose = tru    
 40   //NOTE : we assume an ortho camera.             
 41   if(!a_ww||!a_wh) {                              
 42     if(a_verbose) {                               
 43       a_out << "tools::center_adjust :"           
 44             << " null viewer width or height."    
 45             << std::endl;                         
 46     }                                             
 47     a_dx = 0;a_dy = 0;a_dz = 0;                   
 48     return false;                                 
 49   }                                               
 50   sg::bbox_action _action(a_out);                 
 51   a_node.bbox(_action);                           
 52   if(!_action.box().get_size(a_dx,a_dy,a_dz))     
 53     if(a_verbose) {                               
 54       a_out << "tools::center_adjust :"           
 55             << " empty box."                      
 56             << std::endl;                         
 57     }                                             
 58     a_dx = 0;a_dy = 0;a_dz = 0;                   
 59     return false;                                 
 60   }                                               
 61   if(!a_dx||!a_dy) {                              
 62     if(a_verbose) {                               
 63       a_out << "tools::center_adjust :"           
 64             << " dx or dy null."                  
 65             << std::endl;                         
 66     }                                             
 67     a_dx = 0;a_dy = 0;a_dz = 0;                   
 68     return false;                                 
 69   }                                               
 70   vec3f c;                                        
 71   if(!_action.box().center(c)) {                  
 72     if(a_verbose) {                               
 73       a_out << "tools::center_adjust :"           
 74             << " can't get box center."           
 75             << std::endl;                         
 76     }                                             
 77     a_dx = 0;a_dy = 0;a_dz = 0;                   
 78     return false;                                 
 79   }                                               
 80   float vp_aspect = float(a_ww)/float(a_wh);      
 81   float scene_aspect = float(a_dx)/float(a_dy)    
 82   //::printf("debug : set_tsf : %d %d : %g %g     
 83   //    a_ww,a_wh,a_dx,a_dy,a_dz,vp_aspect,sce    
 84   float scale;                                    
 85   if(vp_aspect>=scene_aspect) {                   
 86     scale = a_height/a_dy;                        
 87   } else {                                        
 88     scale = (vp_aspect*a_height)/a_dx;            
 89   }                                               
 90   a_tsf.set_scale(scale,scale,scale);             
 91   a_tsf.mul_translate(-c.x(),-c.y(),0);           
 92   return true;                                    
 93 }                                                 
 94                                                   
 95 inline bool center_adjust(std::ostream& a_out,    
 96                           sg::node& a_node,sg:    
 97                           unsigned int a_ww,un    
 98                           float a_height,bool     
 99   float dx,dy,dz;                                 
100   return center_adjust(a_out,a_node,a_tsf,a_ww    
101                        dx,dy,dz,a_verbose);       
102 }                                                 
103                                                   
104 }                                                 
105                                                   
106 #endif