void AnimationControl::loadCharacters(list<Object*>& render_list) { data_manager.addFileSearchPath(AMC_MOTION_FILE_PATH); char* ASF_filename = NULL; char* AMC_filename = NULL; try { ASF_filename = data_manager.findFile(character_ASF.c_str()); if (ASF_filename == NULL) { logout << "AnimationControl::loadCharacters: Unable to find character ASF file <" << character_ASF << ">. Aborting load." << endl; throw BasicException("ABORT"); } AMC_filename = data_manager.findFile(character_AMC.c_str()); if (AMC_filename == NULL) { logout << "AnimationControl::loadCharacters: Unable to find character AMC file <" << character_AMC << ">. Aborting load." << endl; throw BasicException("ABORT"); } pair<Skeleton*, MotionSequence*> read_result; try { read_result = data_manager.readASFAMC(ASF_filename, AMC_filename); } catch (const DataManagementException& dme) { logout << "AnimationControl::loadCharacters: Unable to load character data files. Aborting load." << endl; logout << " Failure due to " << dme.msg << endl; throw BasicException("ABORT"); } Skeleton* skel = read_result.first; MotionSequence* ms = read_result.second; MotionSequenceController* controller = new MotionSequenceController(ms); // create rendering model for the character and put the character's // bone objects in the rendering list Color color(1.0f,0.4f,0.3f); skel->constructRenderObject(render_list, color); // attach motion controller to animated skeleton skel->attachMotionController(controller); // create a character to link all the pieces together. string d1 = string("skeleton: ") + character_ASF; string d2 = string("motion: ") + character_AMC; skel->setDescription1(d1.c_str()); skel->setDescription2(d2.c_str()); character = skel; } catch (BasicException&) { } strDelete(ASF_filename); ASF_filename = NULL; strDelete(AMC_filename); AMC_filename = NULL; ready = true; }
/** Reads XML tags from an input file. */ void Parser::parse() { Tag tag; // Read and process tags tags.clear(); skipWhitespace(); try { while (file) { if (character != '<') { throw BasicException("[Parser] Tags must start with '<'."); } else if (match("<!--")) { skip("-->"); } else { tag = create(findTag()); tag.setFilename(filename); tag.setLine(lineNumber); tags.push_back(tag); } skipWhitespace(); } file.close(); } catch (BasicException e) { file.close(); BasicException ex; ex << Tag::toLocation(filename, lineNumber) << e.what(); throw ex; } }
void CellVelocityPlugin::readXML(XMLPullParser &in){ in.skip(TEXT); unsigned int size=2; unsigned int enoughData=2; while (in.check(START_ELEMENT)) { if (in.getName() == "VelocityDataHistorySize") { size = BasicString::parseUInteger(in.matchSimple()); } else if (in.getName() == "EnoughDataThreshold") { enoughData= BasicString::parseUInteger(in.matchSimple()); } else { throw BasicException(string("Unexpected element '") + in.getName() + "'!", in.getLocation()); } in.skip(TEXT); } cldequeCapacity=size; enoughDataThreshold=enoughData; ASSERT_OR_THROW("capacity must be at least 2 " , cldequeCapacity >= 2 ); ASSERT_OR_THROW("capacity must be >= enoughDataThreshold " , cldequeCapacity >= enoughDataThreshold ); }
/** Returns the value in an attribute key/value pair. * * @throw BasicException if there is no text between the quotes. */ string Parser::findValueIn(const string &text) { size_t index; // Return after equals sign index = text.find('='); if ((text.length() - index) <= 3) { throw BasicException("[Parser] Detected empty attribute."); } return Text::trim(text.substr(index+1), " '\""); }
/** Returns the key in an attribute key/value pair. * * @throw BasicException if attribute does not have an equals sign. */ string Parser::findKeyIn(const string &text) { size_t index; // Return up to equals sign index = text.find('='); if (index > text.length()) { throw BasicException("[Parser] Detected attribute without equals sign."); } return Text::trim(text.substr(0, index)); }
/** Creates a blank texture with characteristics specified by @e order. */ TextureInvoice TextureFactory::create(const TextureOrder &order) { // Give to correct builder switch (order.type) { case GL_TEXTURE_2D: return builder2D.build(order); case GL_TEXTURE_1D: case GL_TEXTURE_3D: default: throw BasicException("[TextureFactory] Order type not supported."); } }
void MotionGraphController::readInMotionSequences() { cout << "reading motion Sequences" << endl; namespace fs = ::boost::filesystem; fs::path p(BVH_MOTION_FILE_PATHMOTIONS); if (!exists(p)) // does p actually exist? cout << "doesn't exist" << endl; fs::directory_iterator end_itr; // cycle through the directory for (fs::directory_iterator itr(p); itr != end_itr; ++itr) { // If it's not a directory, list it. If you want to list directories too, just remove this check. if (is_regular_file(itr->path())) { // assign current file name to current_file and echo it out to the console. string current_file = itr->path().string(); current_file = itr->path().filename().string(); cout << current_file << endl; DataManager dataman; dataman.addFileSearchPath(BVH_MOTION_FILE_PATHMOTIONS); char* BVH_filename = NULL; string character_BVH2(current_file); try { BVH_filename = dataman.findFile(character_BVH2.c_str()); if (BVH_filename == NULL) { logout << "AnimationControl::loadCharacters: Unable to find character BVH file <" << character_BVH2 << ">. Aborting load." << endl; throw BasicException("ABORT"); } pair<Skeleton*, MotionSequence*> read_result; try { read_result = data_manager.readBVH(BVH_filename); } catch (const DataManagementException& dme) { logout << "AnimationControl::loadCharacters: Unable to load character data files. Aborting load." << endl; logout << " Failure due to " << dme.msg << endl; throw BasicException("ABORT"); } Skeleton* skel = read_result.first; MotionSequence * ms = read_result.second; std::string x = current_file; char *y = new char[x.length() + 1]; std::strcpy(y, x.c_str()); //set the ID aka filename ms->setId(y); delete[] y; //scale each motion sequence once ms->scaleChannel(CHANNEL_ID(0, CT_TX), character_size_scale); ms->scaleChannel(CHANNEL_ID(0, CT_TY), character_size_scale); ms->scaleChannel(CHANNEL_ID(0, CT_TZ), character_size_scale); MotionSequenceContainer test; test.MS = ms; test.SeqID = current_file; MsVector.push_back(test); cout << "done loading: "<<current_file << MsVector.size() << endl; } catch (BasicException& e) { cout << e.msg << endl; } } } cout << "the size of the vector is : " << MsVector.size() << endl; }
/** @throw BasicException if code tries to copy a GlyphTexture. */ GlyphTexture::GlyphTexture(const GlyphTexture >) : font(font) { throw BasicException("[GlyphTexture] Unsupported copy!"); }