Load a model and return its ID
| 107 | |
| 108 | // Load a model and return its ID |
| 109 | int Models::loadModel(const std::string& rel_path, char flags, const std::string& store_name) { |
| 110 | int which_model = -1; |
| 111 | const std::string& check_name = store_name.empty() ? rel_path : store_name; |
| 112 | // Check if the model is already loaded |
| 113 | std::map<std::string, int>::iterator iter = name_map.find(check_name); |
| 114 | if (iter != name_map.end()) { |
| 115 | which_model = iter->second; |
| 116 | } |
| 117 | // If model is not loaded; load it |
| 118 | unsigned int i = 0; |
| 119 | if (which_model == -1) { |
| 120 | which_model = AddModel(); |
| 121 | ModelData& md = GetModelData(which_model); |
| 122 | // Check extension |
| 123 | while (i < rel_path.size() && rel_path[i] != '.') { |
| 124 | i++; |
| 125 | } |
| 126 | if (rel_path[i + 1] == 'o') { |
| 127 | md.model.LoadObj(rel_path, flags, check_name); |
| 128 | } |
| 129 | md.name = rel_path; |
| 130 | name_map[check_name] = which_model; |
| 131 | } |
| 132 | return which_model; |
| 133 | } |
| 134 | |
| 135 | // Select which model to draw |
| 136 | void Models::drawModel(int which_model) { |
no test coverage detected