goat3d

changeset 51:fa5c52ea9d59

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 17 Jan 2014 18:16:09 +0200
parents 9ef9de80649c
children cb5414f406eb
files src/goat3d.cc src/goat3d_impl.h src/goat3d_readxml.cc src/goat3d_write.cc src/goat3d_writexml.cc
diffstat 5 files changed, 53 insertions(+), 5 deletions(-) [+]
line diff
     1.1 --- a/src/goat3d.cc	Sun Dec 29 06:01:59 2013 +0200
     1.2 +++ b/src/goat3d.cc	Fri Jan 17 18:16:09 2014 +0200
     1.3 @@ -294,7 +294,7 @@
     1.4  
     1.5  GOAT3DAPI void goat3d_set_mtl_attrib_map(struct goat3d_material *mtl, const char *attrib, const char *mapname)
     1.6  {
     1.7 -	(*mtl)[attrib].map = goat3d_clean_filename(mapname);
     1.8 +	(*mtl)[attrib].map = clean_filename(mapname);
     1.9  }
    1.10  
    1.11  GOAT3DAPI const char *goat3d_get_mtl_attrib_map(struct goat3d_material *mtl, const char *attrib)
    1.12 @@ -909,7 +909,7 @@
    1.13  	return ftell((FILE*)uptr);
    1.14  }
    1.15  
    1.16 -std::string goat3d_clean_filename(const char *str)
    1.17 +std::string g3dimpl::clean_filename(const char *str)
    1.18  {
    1.19  	const char *last_slash = strrchr(str, '/');
    1.20  	if(!last_slash) {
     2.1 --- a/src/goat3d_impl.h	Sun Dec 29 06:01:59 2013 +0200
     2.2 +++ b/src/goat3d_impl.h	Fri Jan 17 18:16:09 2014 +0200
     2.3 @@ -23,7 +23,7 @@
     2.4  #define VECDATA(type, data, num) \
     2.5  	MOVE(std::vector<type>((type*)(data), (type*)(data) + (num)))
     2.6  
     2.7 -std::string goat3d_clean_filename(const char *str);
     2.8 +std::string clean_filename(const char *str);
     2.9  
    2.10  
    2.11  class Scene {
     3.1 --- a/src/goat3d_readxml.cc	Sun Dec 29 06:01:59 2013 +0200
     3.2 +++ b/src/goat3d_readxml.cc	Fri Jan 17 18:16:09 2014 +0200
     3.3 @@ -66,6 +66,49 @@
     3.4  	return true;
     3.5  }
     3.6  
     3.7 +bool Scene::load_anim_xml(goat3d_io *io)
     3.8 +{
     3.9 +	long bytes = io->seek(0, SEEK_END, io->cls);
    3.10 +	io->seek(0, SEEK_SET, io->cls);
    3.11 +
    3.12 +	char *buf = new char[bytes];
    3.13 +	if(io->read(buf, bytes, io->cls) < bytes) {
    3.14 +		logmsg(LOG_ERROR, "failed to read XML animation file\n");
    3.15 +		delete [] buf;
    3.16 +		return false;
    3.17 +	}
    3.18 +
    3.19 +	XMLDocument xml;
    3.20 +	XMLError err = xml.Parse(buf, bytes);
    3.21 +	if(err) {
    3.22 +		logmsg(LOG_ERROR, "failed to parse XML animation file: %s\n%s\n", xml.GetErrorStr1(),
    3.23 +				xml.GetErrorStr2());
    3.24 +		delete [] buf;
    3.25 +		return false;
    3.26 +	}
    3.27 +
    3.28 +	XMLElement *root = xml.RootElement();
    3.29 +	if(strcmp(root->Name(), "anim") != 0) {
    3.30 +		logmsg(LOG_ERROR, "invalid XML file, root node is not <anim>\n");
    3.31 +		delete [] buf;
    3.32 +		return false;
    3.33 +	}
    3.34 +
    3.35 +	XMLElement *elem;
    3.36 +
    3.37 +	elem = root->FirstChildElement();
    3.38 +	while(elem) {
    3.39 +		const char *elem_name = elem->Name();
    3.40 +
    3.41 +		if(strcmp(elem_name, "name") == 0) {
    3.42 +		} else if(strcmp(elem_name, "attr") == 0) {
    3.43 +		}
    3.44 +		elem = elem->NextSiblingElement();
    3.45 +	}
    3.46 +
    3.47 +	delete [] buf;
    3.48 +	return true;
    3.49 +}
    3.50  
    3.51  static Material *read_material(Scene *scn, XMLElement *xml_mtl)
    3.52  {
     4.1 --- a/src/goat3d_write.cc	Sun Dec 29 06:01:59 2013 +0200
     4.2 +++ b/src/goat3d_write.cc	Fri Jan 17 18:16:09 2014 +0200
     4.3 @@ -68,6 +68,11 @@
     4.4  	return false;
     4.5  }
     4.6  
     4.7 +bool Scene::save_anim(const XFormNode *node, goat3d_io *io) const
     4.8 +{
     4.9 +	return false;
    4.10 +}
    4.11 +
    4.12  
    4.13  #if 0
    4.14  static long save_env(const Scene *scn, long offset, goat3d_io *io)
     5.1 --- a/src/goat3d_writexml.cc	Sun Dec 29 06:01:59 2013 +0200
     5.2 +++ b/src/goat3d_writexml.cc	Fri Jan 17 18:16:09 2014 +0200
     5.3 @@ -118,7 +118,7 @@
     5.4  	if(mesh->material) {
     5.5  		xmlout(io, level + 1, "<material string=\"%s\"/>\n", mesh->material->name.c_str());
     5.6  	}
     5.7 -	xmlout(io, level + 1, "<file string=\"%s\"/>\n", goat3d_clean_filename(mesh_filename).c_str());
     5.8 +	xmlout(io, level + 1, "<file string=\"%s\"/>\n", clean_filename(mesh_filename).c_str());
     5.9  	xmlout(io, level, "</mesh>\n\n");
    5.10  	return true;
    5.11  }
    5.12 @@ -180,7 +180,7 @@
    5.13  
    5.14  static bool write_node_anim(goat3d_io *io, const XFormNode *node, int level)
    5.15  {
    5.16 -	/* NOTE: the order of names must correspond to the order of
    5.17 +	/* NOTE: the order of names must correspond to the order of the
    5.18  	 * XFormNode::POSITION_TRACK/ROTATION_TRACK/SCALING_TRACK enum
    5.19  	 */
    5.20  	static const char *attr_names[] = { "position", "rotation", "scaling" };