| 1210 | } |
| 1211 | |
| 1212 | Ref<SceneGraph::Node> XMLLoader::loadCurves(const Ref<XML>& xml, RTCGeometryType type) |
| 1213 | { |
| 1214 | Ref<SceneGraph::MaterialNode> material = loadMaterial(xml->child("material")); |
| 1215 | Ref<SceneGraph::HairSetNode> mesh = new SceneGraph::HairSetNode(type,material,BBox1f(0,1),0); |
| 1216 | |
| 1217 | if (Ref<XML> animation = xml->childOpt("animated_positions")) { |
| 1218 | for (size_t i=0; i<animation->size(); i++) { |
| 1219 | mesh->positions.push_back(loadVec3ffArray(animation->child(i))); |
| 1220 | } |
| 1221 | } else { |
| 1222 | mesh->positions.push_back(loadVec3ffArray(xml->childOpt("positions"))); |
| 1223 | if (xml->hasChild("positions2")) { |
| 1224 | mesh->positions.push_back(loadVec3ffArray(xml->childOpt("positions2"))); |
| 1225 | } |
| 1226 | } |
| 1227 | |
| 1228 | if (Ref<XML> animation = xml->childOpt("animated_normals")) { |
| 1229 | for (size_t i=0; i<animation->size(); i++) { |
| 1230 | mesh->normals.push_back(loadVec3faArray(animation->child(i))); |
| 1231 | } |
| 1232 | } else if (Ref<XML> normals = xml->childOpt("normals")) { |
| 1233 | mesh->normals.push_back(loadVec3faArray(normals)); |
| 1234 | } |
| 1235 | |
| 1236 | if (type == RTC_GEOMETRY_TYPE_FLAT_HERMITE_CURVE || |
| 1237 | type == RTC_GEOMETRY_TYPE_ROUND_HERMITE_CURVE || |
| 1238 | type == RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_HERMITE_CURVE) |
| 1239 | { |
| 1240 | if (Ref<XML> animation = xml->childOpt("animated_tangents")) { |
| 1241 | for (size_t i=0; i<animation->size(); i++) { |
| 1242 | mesh->tangents.push_back(loadVec3ffArray(animation->child(i))); |
| 1243 | } |
| 1244 | } else if (Ref<XML> tangents = xml->childOpt("tangents")) { |
| 1245 | mesh->tangents.push_back(loadVec3ffArray(tangents)); |
| 1246 | } |
| 1247 | } |
| 1248 | |
| 1249 | if (type == RTC_GEOMETRY_TYPE_NORMAL_ORIENTED_HERMITE_CURVE) |
| 1250 | { |
| 1251 | if (Ref<XML> animation = xml->childOpt("animated_normal_derivatives")) { |
| 1252 | for (size_t i=0; i<animation->size(); i++) { |
| 1253 | mesh->dnormals.push_back(loadVec3faArray(animation->child(i))); |
| 1254 | } |
| 1255 | } else if (Ref<XML> dnormals = xml->childOpt("normal_derivatives")) { |
| 1256 | mesh->dnormals.push_back(loadVec3faArray(dnormals)); |
| 1257 | } |
| 1258 | } |
| 1259 | |
| 1260 | std::vector<unsigned> indices = loadUIntArray(xml->childOpt("indices")); |
| 1261 | std::vector<unsigned> curveid = loadUIntArray(xml->childOpt("curveid")); |
| 1262 | curveid.resize(indices.size(),0); |
| 1263 | mesh->hairs.resize(indices.size()); |
| 1264 | for (size_t i=0; i<indices.size(); i++) { |
| 1265 | mesh->hairs[i] = SceneGraph::HairSetNode::Hair(indices[i], |
| 1266 | curveid[i]); |
| 1267 | } |
| 1268 | |
| 1269 | mesh->flags = loadUCharArray(xml->childOpt("flags")); |
nothing calls this directly
no test coverage detected