| 1026 | } |
| 1027 | |
| 1028 | void DotSceneLoader::writeNode(pugi::xml_node& parentXML, const SceneNode* n) |
| 1029 | { |
| 1030 | auto nodeXML = parentXML.append_child("node"); |
| 1031 | if(!n->getName().empty()) |
| 1032 | nodeXML.append_attribute("name") = n->getName().c_str(); |
| 1033 | |
| 1034 | auto pos = nodeXML.append_child("position"); |
| 1035 | write(pos, n->getPosition()); |
| 1036 | |
| 1037 | auto scale = nodeXML.append_child("scale"); |
| 1038 | write(scale, n->getScale()); |
| 1039 | |
| 1040 | auto rot = nodeXML.append_child("rotation"); |
| 1041 | rot.append_attribute("qw") = StringConverter::toString(n->getOrientation().w).c_str(); |
| 1042 | rot.append_attribute("qx") = StringConverter::toString(n->getOrientation().x).c_str(); |
| 1043 | rot.append_attribute("qy") = StringConverter::toString(n->getOrientation().y).c_str(); |
| 1044 | rot.append_attribute("qz") = StringConverter::toString(n->getOrientation().z).c_str(); |
| 1045 | |
| 1046 | for(auto mo : n->getAttachedObjects()) |
| 1047 | { |
| 1048 | if(auto c = dynamic_cast<Camera*>(mo)) |
| 1049 | { |
| 1050 | auto camera = nodeXML.append_child("camera"); |
| 1051 | camera.append_attribute("name") = c->getName().c_str(); |
| 1052 | auto clipping = camera.append_child("clipping"); |
| 1053 | clipping.append_attribute("near") = StringConverter::toString(c->getNearClipDistance()).c_str(); |
| 1054 | clipping.append_attribute("far") = StringConverter::toString(c->getFarClipDistance()).c_str(); |
| 1055 | continue; |
| 1056 | } |
| 1057 | |
| 1058 | if (auto l = dynamic_cast<Light*>(mo)) |
| 1059 | { |
| 1060 | auto light = nodeXML.append_child("light"); |
| 1061 | light.append_attribute("name") = l->getName().c_str(); |
| 1062 | light.append_attribute("castShadows") = StringConverter::toString(l->getCastShadows()).c_str(); |
| 1063 | |
| 1064 | if(!l->isVisible()) |
| 1065 | light.append_attribute("visible") = "false"; |
| 1066 | |
| 1067 | auto diffuse = light.append_child("colourDiffuse"); |
| 1068 | write(diffuse, l->getDiffuseColour()); |
| 1069 | auto specular = light.append_child("colourSpecular"); |
| 1070 | write(specular, l->getSpecularColour()); |
| 1071 | switch (l->getType()) |
| 1072 | { |
| 1073 | case Light::LT_POINT: |
| 1074 | light.append_attribute("type") = "point"; |
| 1075 | break; |
| 1076 | case Light::LT_DIRECTIONAL: |
| 1077 | light.append_attribute("type") = "directional"; |
| 1078 | break; |
| 1079 | case Light::LT_SPOTLIGHT: |
| 1080 | light.append_attribute("type") = "spot"; |
| 1081 | break; |
| 1082 | case Light::LT_RECTLIGHT: |
| 1083 | light.append_attribute("type") = "rect"; |
| 1084 | break; |
| 1085 | } |
nothing calls this directly
no test coverage detected