MCPcopy Create free account
hub / github.com/assimp/assimp / ParseNodeAttributes

Method ParseNodeAttributes

code/AssetLib/Irr/IRRLoader.cpp:838–977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

836}
837
838void IRRImporter::ParseNodeAttributes(pugi::xml_node &attributesNode, IRRImporter::Node *nd, BatchLoader &batch) {
839 ai_assert(!ASSIMP_stricmp(attributesNode.name(), "attributes")); // Node must be <attributes>
840 ai_assert(nd != nullptr); // dude
841
842 // Big switch statement that tests for various tags inside <attributes>
843 // and applies them to nd
844 // I don't believe nodes have boolean attributes
845 for (pugi::xml_node &attribute : attributesNode.children()) {
846 if (attribute.type() != pugi::node_element) continue;
847 if (!ASSIMP_stricmp(attribute.name(), "vector3d")) { // <vector3d />
848 VectorProperty prop;
849 ReadVectorProperty(prop, attribute);
850 if (prop.name == "Position") {
851 nd->position = prop.value;
852 } else if (prop.name == "Rotation") {
853 nd->rotation = prop.value;
854 } else if (prop.name == "Scale") {
855 nd->scaling = prop.value;
856 } else if (Node::CAMERA == nd->type) {
857 aiCamera *cam = cameras.back();
858 if (prop.name == "Target") {
859 cam->mLookAt = prop.value;
860 } else if (prop.name == "UpVector") {
861 cam->mUp = prop.value;
862 }
863 }
864 } else if (!ASSIMP_stricmp(attribute.name(), "float")) { // <float />
865 FloatProperty prop;
866 ReadFloatProperty(prop, attribute);
867 if (prop.name == "FramesPerSecond" && Node::ANIMMESH == nd->type) {
868 nd->framesPerSecond = prop.value;
869 } else if (Node::CAMERA == nd->type) {
870 /* This is the vertical, not the horizontal FOV.
871 * We need to compute the right FOV from the
872 * screen aspect which we don't know yet.
873 */
874 if (prop.name == "Fovy") {
875 cameras.back()->mHorizontalFOV = prop.value;
876 } else if (prop.name == "Aspect") {
877 cameras.back()->mAspect = prop.value;
878 } else if (prop.name == "ZNear") {
879 cameras.back()->mClipPlaneNear = prop.value;
880 } else if (prop.name == "ZFar") {
881 cameras.back()->mClipPlaneFar = prop.value;
882 }
883 } else if (Node::LIGHT == nd->type) {
884 /* Additional light information
885 */
886 if (prop.name == "Attenuation") {
887 lights.back()->mAttenuationLinear = prop.value;
888 } else if (prop.name == "OuterCone") {
889 lights.back()->mAngleOuterCone = AI_DEG_TO_RAD(prop.value);
890 } else if (prop.name == "InnerCone") {
891 lights.back()->mAngleInnerCone = AI_DEG_TO_RAD(prop.value);
892 }
893 }
894 // radius of the sphere to be generated -
895 // or alternatively, size of the cube

Callers

nothing calls this directly

Calls 6

ASSIMP_stricmpFunction · 0.85
childrenMethod · 0.80
AddLoadRequestMethod · 0.80
nameMethod · 0.45
typeMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected