goat3d
diff src/goat3d_readxml.cc @ 51:fa5c52ea9d59
foo
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 17 Jan 2014 18:16:09 +0200 |
parents | 498ca7ac7047 |
children | cb5414f406eb |
line diff
1.1 --- a/src/goat3d_readxml.cc Sun Dec 29 06:01:59 2013 +0200 1.2 +++ b/src/goat3d_readxml.cc Fri Jan 17 18:16:09 2014 +0200 1.3 @@ -66,6 +66,49 @@ 1.4 return true; 1.5 } 1.6 1.7 +bool Scene::load_anim_xml(goat3d_io *io) 1.8 +{ 1.9 + long bytes = io->seek(0, SEEK_END, io->cls); 1.10 + io->seek(0, SEEK_SET, io->cls); 1.11 + 1.12 + char *buf = new char[bytes]; 1.13 + if(io->read(buf, bytes, io->cls) < bytes) { 1.14 + logmsg(LOG_ERROR, "failed to read XML animation file\n"); 1.15 + delete [] buf; 1.16 + return false; 1.17 + } 1.18 + 1.19 + XMLDocument xml; 1.20 + XMLError err = xml.Parse(buf, bytes); 1.21 + if(err) { 1.22 + logmsg(LOG_ERROR, "failed to parse XML animation file: %s\n%s\n", xml.GetErrorStr1(), 1.23 + xml.GetErrorStr2()); 1.24 + delete [] buf; 1.25 + return false; 1.26 + } 1.27 + 1.28 + XMLElement *root = xml.RootElement(); 1.29 + if(strcmp(root->Name(), "anim") != 0) { 1.30 + logmsg(LOG_ERROR, "invalid XML file, root node is not <anim>\n"); 1.31 + delete [] buf; 1.32 + return false; 1.33 + } 1.34 + 1.35 + XMLElement *elem; 1.36 + 1.37 + elem = root->FirstChildElement(); 1.38 + while(elem) { 1.39 + const char *elem_name = elem->Name(); 1.40 + 1.41 + if(strcmp(elem_name, "name") == 0) { 1.42 + } else if(strcmp(elem_name, "attr") == 0) { 1.43 + } 1.44 + elem = elem->NextSiblingElement(); 1.45 + } 1.46 + 1.47 + delete [] buf; 1.48 + return true; 1.49 +} 1.50 1.51 static Material *read_material(Scene *scn, XMLElement *xml_mtl) 1.52 {