Panda3D
|
00001 // Filename: loaderOptions.cxx 00002 // Created by: drose (05Oct05) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "loaderOptions.h" 00016 #include "config_util.h" 00017 #include "indent.h" 00018 00019 //////////////////////////////////////////////////////////////////// 00020 // Function: LoaderOptions::Constructor 00021 // Access: Published 00022 // Description: 00023 //////////////////////////////////////////////////////////////////// 00024 LoaderOptions:: 00025 LoaderOptions(int flags) : 00026 _flags(flags), 00027 _texture_flags(0), 00028 _texture_num_views(0), 00029 _auto_texture_scale(ATS_unspecified) 00030 { 00031 // Shadowing the variables in config_util for static init ordering 00032 // issues. 00033 static ConfigVariableBool *preload_textures; 00034 static ConfigVariableBool *preload_simple_textures; 00035 if (preload_textures == NULL) { 00036 preload_textures = new ConfigVariableBool("preload-textures", true); 00037 } 00038 if (preload_simple_textures == NULL) { 00039 preload_simple_textures = new ConfigVariableBool("preload-simple-textures", false); 00040 } 00041 00042 if (*preload_textures) { 00043 _texture_flags |= TF_preload; 00044 } 00045 if (*preload_simple_textures) { 00046 _texture_flags |= TF_preload_simple; 00047 } 00048 } 00049 00050 //////////////////////////////////////////////////////////////////// 00051 // Function: LoaderOptions::output 00052 // Access: Published 00053 // Description: 00054 //////////////////////////////////////////////////////////////////// 00055 void LoaderOptions:: 00056 output(ostream &out) const { 00057 out << "LoaderOptions("; 00058 00059 string sep = ""; 00060 write_flag(out, sep, "LF_search", LF_search); 00061 write_flag(out, sep, "LF_report_errors", LF_report_errors); 00062 if ((_flags & LF_convert_anim) == LF_convert_anim) { 00063 write_flag(out, sep, "LF_convert_anim", LF_convert_anim); 00064 } else { 00065 write_flag(out, sep, "LF_convert_skeleton", LF_convert_skeleton); 00066 write_flag(out, sep, "LF_convert_channels", LF_convert_channels); 00067 } 00068 if ((_flags & LF_no_cache) == LF_no_cache) { 00069 write_flag(out, sep, "LF_no_cache", LF_no_cache); 00070 } else { 00071 write_flag(out, sep, "LF_no_disk_cache", LF_no_disk_cache); 00072 write_flag(out, sep, "LF_no_ram_cache", LF_no_ram_cache); 00073 } 00074 write_flag(out, sep, "LF_allow_instance", LF_allow_instance); 00075 if (sep.empty()) { 00076 out << "0"; 00077 } 00078 00079 out << ", "; 00080 00081 sep = ""; 00082 write_texture_flag(out, sep, "TF_preload", TF_preload); 00083 write_texture_flag(out, sep, "TF_preload_simple", TF_preload_simple); 00084 write_texture_flag(out, sep, "TF_allow_1d", TF_allow_1d); 00085 write_texture_flag(out, sep, "TF_generate_mipmaps", TF_generate_mipmaps); 00086 if (sep.empty()) { 00087 out << "0"; 00088 } 00089 00090 if (_auto_texture_scale != ATS_unspecified) { 00091 out << ", ATS_" << _auto_texture_scale; 00092 } 00093 00094 out << ")"; 00095 } 00096 00097 //////////////////////////////////////////////////////////////////// 00098 // Function: LoaderOptions::write_flag 00099 // Access: Private 00100 // Description: Used to implement output(). 00101 //////////////////////////////////////////////////////////////////// 00102 void LoaderOptions:: 00103 write_flag(ostream &out, string &sep, 00104 const string &flag_name, int flag) const { 00105 if ((_flags & flag) == flag) { 00106 out << sep << flag_name; 00107 sep = " | "; 00108 } 00109 } 00110 00111 //////////////////////////////////////////////////////////////////// 00112 // Function: LoaderOptions::write_texture_flag 00113 // Access: Private 00114 // Description: Used to implement output(). 00115 //////////////////////////////////////////////////////////////////// 00116 void LoaderOptions:: 00117 write_texture_flag(ostream &out, string &sep, 00118 const string &flag_name, int flag) const { 00119 if ((_texture_flags & flag) == flag) { 00120 out << sep << flag_name; 00121 sep = " | "; 00122 } 00123 }