// http://tfc.duke.free.fr/old/models/md2.htm Assets::EntityModel* Md2Parser::doParseModel() { const char* cursor = m_begin; const int ident = readInt<int32_t>(cursor); const int version = readInt<int32_t>(cursor); if (ident != Md2Layout::Ident) throw AssetException() << "Unknown MD2 model ident: " << ident; if (version != Md2Layout::Version) throw AssetException() << "Unknown MD2 model version: " << version; /*const size_t skinWidth =*/ readSize<int32_t>(cursor); /*const size_t skinHeight =*/ readSize<int32_t>(cursor); /*const size_t frameSize =*/ readSize<int32_t>(cursor); const size_t skinCount = readSize<int32_t>(cursor); const size_t frameVertexCount = readSize<int32_t>(cursor); /* const size_t texCoordCount =*/ readSize<int32_t>(cursor); /* const size_t triangleCount =*/ readSize<int32_t>(cursor); const size_t commandCount = readSize<int32_t>(cursor); const size_t frameCount = readSize<int32_t>(cursor); const size_t skinOffset = readSize<int32_t>(cursor); /* const size_t texCoordOffset =*/ readSize<int32_t>(cursor); /* const size_t triangleOffset =*/ readSize<int32_t>(cursor); const size_t frameOffset = readSize<int32_t>(cursor); const size_t commandOffset = readSize<int32_t>(cursor); const Md2SkinList skins = parseSkins(m_begin + skinOffset, skinCount); const Md2FrameList frames = parseFrames(m_begin + frameOffset, frameCount, frameVertexCount); const Md2MeshList meshes = parseMeshes(m_begin + commandOffset, commandCount); return buildModel(skins, frames, meshes); }
void FramedReader::onNextImpl(std::unique_ptr<folly::IOBuf> payload) noexcept { streamRequested_ = false; if (payload) { payloadQueue_.append(std::move(payload)); parseFrames(); } requestStream(); }
void EnemyScout::init() { maxHealth = health = 25; maxSpeed = 225; value = 150; int cols = 1; int rows = 2; parseFrames(cols, rows); sprite = frames.at(polarity); //set Gun pos gun.setPoint(getX(), getY() + sprite->getHeight() /2); }
void Spritesheet::load(const std::string& path) { // Load the image itself into a texture using GraphicsUtil std::string imgPath(path); imgPath += IMG_EXTENSION; DEBUG("Loading spritesheet image \"%s\"...", imgPath.c_str()); texture = new Texture(imgPath); size = texture->getSize(); // Load in the spritesheet data file, which tells the engine where // each frame is in the image std::string dataPath(path); dataPath += DATA_EXTENSION; DEBUG("Loading spritesheet data \"%s\"...", dataPath.c_str()); std::ifstream input(dataPath.c_str()); if(!input.is_open()) { T_T(std::string("Error opening file: ") + dataPath); } // Read in the JSON data in the file Json::Value jsonRoot; input >> jsonRoot; if(jsonRoot.isNull()) { DEBUG("Unexpected root element name."); T_T("Failed to parse spritesheet data."); } parseFrames(jsonRoot); parseAnimations(jsonRoot); DEBUG("Spritesheet constructed!"); }
void FramedReader::requestImpl(size_t n) noexcept { allowance_.release(n); parseFrames(); requestStream(); }
bool KNMusicLRCLyricsParser::parseData(const QString &lyricsTextData, QList<qint64> &positionList, QStringList &textList) { //Clear the position list and text list. positionList.clear(); textList.clear(); //Split the lyrics text data. QStringList lyricsRawData=lyricsTextData.split(QRegExp("\n"), QString::SkipEmptyParts); QList<LyricsLine> lyricsLineList; //Remove the same line in the lyrics raw data. lyricsRawData.removeDuplicates(); //Parse the lyrics raw data. while(!lyricsRawData.isEmpty()) { //Get the first line of the current list and remove all spaces. QString currentLine=lyricsRawData.takeFirst().simplified(); //Find frames in the current line. QRegularExpressionMatchIterator frameMatcher= m_frameCatchRegExp.globalMatch(currentLine); int lastPosition=0; QLinkedList<QString> frameLists; //Get all the frames. while(frameMatcher.hasNext()) { QRegularExpressionMatch matchedFrame=frameMatcher.next(); //Check is the current matched frame is at the last position. //An example is: // [00:00:01] Won't chu kiss me![00:00:03]Saikou no if(matchedFrame.capturedStart()!=lastPosition) { //Then we should pick out the data before the current start and //last position. //Like 'Won't chu kiss me!' in the example. QString text=currentLine.mid(lastPosition, matchedFrame.capturedStart()-lastPosition); //Parse the datas to frame lists. while(!frameLists.isEmpty()) { parseFrames(frameLists.takeFirst(), text, lyricsLineList); } } //Add current frame to frame list. frameLists.append(currentLine.mid(matchedFrame.capturedStart(), matchedFrame.capturedLength())); //Update the last position. lastPosition=matchedFrame.capturedEnd(); } //Remove the previous datas, and parse the left datas to frame lists. currentLine.remove(0, lastPosition); while(!frameLists.isEmpty()) { parseFrames(frameLists.takeFirst(), currentLine, lyricsLineList); } } //Check is the lyrics line list is empty or not, if it's empty, means we //can't parse it. if(lyricsLineList.isEmpty()) { return false; } //Sorr the lyrics line. //- Why stable sort? // Because there might be some frames at the same time. Display them with //their exist order. qStableSort(lyricsLineList.begin(), lyricsLineList.end(), frameLessThan); //Combine the same timestamp lyrics. QMap<qint64, QString> lyricsCombineMap; for(QList<LyricsLine>::iterator i=lyricsLineList.begin(); i!=lyricsLineList.end(); ++i) { lyricsCombineMap.insert((*i).position, lyricsCombineMap.contains((*i).position)? lyricsCombineMap.value((*i).position)+'\n'+(*i).text: (*i).text); } //Export the position and the text. positionList=lyricsCombineMap.keys(); textList=lyricsCombineMap.values(); return true; }