void Trigger::load(const Aurora::GFF3Struct &gff) { Common::UString temp = gff.getString("TemplateResRef"); Common::ScopedPtr<Aurora::GFF3File> utt; if (!temp.empty()) utt.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTT, MKTAG('U', 'T', 'T', ' '))); loadBlueprint(utt->getTopLevel()); if (!utt) warning("Trigger \"%s\" has no blueprint", temp.c_str()); float x, y, z; x = (float)gff.getDouble("XPosition"); y = (float)gff.getDouble("YPosition"); z = (float)gff.getDouble("ZPosition"); glm::vec3 position(x, y, z); setPosition(x, y, z); x = (float)gff.getDouble("XOrientation"); y = (float)gff.getDouble("YOrientation"); z = (float)gff.getDouble("ZOrientation"); glm::vec3 orientation(x, y, z); const Aurora::GFF3List &geometry = gff.getList("Geometry"); for (Aurora::GFF3List::const_iterator p = geometry.begin(); p != geometry.end(); ++p) { x = (float)(*p)->getDouble("PointX"); y = (float)(*p)->getDouble("PointY"); z = (float)(*p)->getDouble("PointZ"); _geometry.push_back(position + glm::vec3(x, y, z)); } }
void Waypoint::load(const Aurora::GFF3Struct &waypoint) { Common::UString temp = waypoint.getString("TemplateResRef"); Common::ScopedPtr<Aurora::GFF3File> utw; if (!temp.empty()) utw.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTW, MKTAG('U', 'T', 'W', ' '))); load(waypoint, utw ? &utw->getTopLevel() : 0); }
void Door::load(const Aurora::GFF3Struct &door) { Common::UString temp = door.getString("TemplateResRef"); Common::ScopedPtr<Aurora::GFF3File> utd; if (!temp.empty()) utd.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTD, MKTAG('U', 'T', 'D', ' '))); Situated::load(door, utd ? &utd->getTopLevel() : 0); setModelState(); }
void Creature::load(const Aurora::GFF3Struct &creature) { Common::UString temp = creature.getString("TemplateResRef"); Common::ScopedPtr<Aurora::GFF3File> utc; if (!temp.empty()) utc.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTC, MKTAG('U', 'T', 'C', ' '))); load(creature, utc ? &utc->getTopLevel() : 0); if (!utc) warning("Creature \"%s\" has no blueprint", _tag.c_str()); }
void TalkTable_GFF::readString05(Entry &entry, bool bigEndian) const { Common::ScopedPtr<Common::SeekableReadStream> huffTree (_gff->getTopLevel().getData(kGFF4HuffTalkStringHuffTree)), bitStream(_gff->getTopLevel().getData(kGFF4HuffTalkStringBitStream)); if (!huffTree || !bitStream) return; Common::SeekableSubReadStreamEndian huffTreeEndian(huffTree.get(), 0, huffTree->size(), bigEndian); Common::SeekableSubReadStreamEndian bitStreamEndian(bitStream.get(), 0, bitStream->size(), bigEndian); readString05(huffTreeEndian, bitStreamEndian, entry); }
void Placeable::load(const Aurora::GFF3Struct &placeable) { Common::UString temp = placeable.getString("TemplateResRef"); Common::ScopedPtr<Aurora::GFF3File> utp; if (!temp.empty()) utp.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTP, MKTAG('U', 'T', 'P', ' '))); Situated::load(placeable, utp ? &utp->getTopLevel() : 0); if (!utp) warning("Placeable \"%s\" has no blueprint", _tag.c_str()); readScripts(utp->getTopLevel()); }
void VPXDecoder::decodeFrame(Graphics::Surface &surface, Common::SeekableReadStream &dataStream) { if (!_initialized) return; // Read all the data from the stream Common::ScopedArray<byte> data(new byte[dataStream.size()]); dataStream.read(data.get(), dataStream.size()); // Perform the actual decode vpx_codec_err_t result = vpx_codec_decode(&_context, data.get(), dataStream.size(), 0, 0); if (result != VPX_CODEC_OK) return; // Try to get the image vpx_codec_iter_t iter = 0; vpx_image_t *image = vpx_codec_get_frame(&_context, &iter); if (!image) return; // Figure out the color range Graphics::YUVToRGBManager::LuminanceScale scale; switch (image->range) { case VPX_CR_STUDIO_RANGE: scale = Graphics::YUVToRGBManager::kScaleITU; break; case VPX_CR_FULL_RANGE: scale = Graphics::YUVToRGBManager::kScaleFull; break; default: return; } // If we don't have it already, create our local surface if (!_surface) _surface.reset(new Graphics::Surface(image->w, image->h)); // Do the conversion based on the color space switch (image->fmt) { case VPX_IMG_FMT_I420: YUVToRGBMan.convert420(scale, _surface->getData(), _surface->getPitch(), image->planes[0], image->planes[1], image->planes[2], image->w, image->h, image->stride[0], image->stride[1]); break; default: return; } // Copy the subarea into the surface for (int y = 0; y < surface.getHeight(); y++) memcpy(surface.getData() + y * surface.getPitch(), _surface->getData() + (y * image->d_h) * image->d_w * 4, image->d_w * 4); }
void Door::load(const Aurora::GFF3Struct &door) { Common::UString temp = door.getString("TemplateResRef"); Common::ScopedPtr<Aurora::GFF3File> utd; if (!temp.empty()) utd.reset(loadOptionalGFF3(temp, Aurora::kFileTypeUTD, MKTAG('U', 'T', 'D', ' '))); Situated::load(door, utd ? &utd->getTopLevel() : 0); if (!utd) warning("Door \"%s\" has no blueprint", _tag.c_str()); if (!_modelName.empty()) { glm::mat4 transform; transform = glm::translate(transform, glm::make_vec3(_position)); transform = glm::rotate(transform, Common::deg2rad(_orientation[3]), glm::make_vec3(_orientation)); _walkmesh.load(_modelName + "0", ::Aurora::kFileTypeDWK, transform); } }
size_t WwRIFFVorbisStream::readBuffer(int16 *buffer, const size_t numSamples) { size_t samples = 0; while (samples < numSamples) { const size_t needSamples = numSamples - samples; const size_t gotSamples = _vorbis->readBuffer(buffer, needSamples); buffer += gotSamples; samples += gotSamples; if (gotSamples < needSamples) { Common::ScopedPtr<Common::SeekableReadStream> packet(createPacket()); if (!packet) { _end = true; break; } _vorbis->queuePacket(packet.release()); } } return samples; }
bool WwRIFFVorbisStream::rewind() { _end = false; Common::ScopedPtr<Common::SeekableReadStream> headerIdentification(generateHeaderIdentification()); Common::ScopedPtr<Common::SeekableReadStream> headerComment(generateHeaderComment()); Common::ScopedPtr<Common::SeekableReadStream> headerSetup(generateHeaderSetup()); #ifdef ENABLE_VORBIS _vorbis.reset(Sound::makePacketizedVorbisStream(*headerIdentification, *headerComment, *headerSetup)); #else throw Common::Exception("Vorbis decoding disabled when building without libvorbis"); #endif _currentOffset = _dataOffset + _firstAudioPacketOffset; return true; }
int WwRIFFVorbisStream::getRate() const { return _vorbis->getRate(); }
int WwRIFFVorbisStream::getChannels() const { return _vorbis->getChannels(); }
int main(int argc, char **argv) { initPlatform(); try { std::vector<Common::UString> args; Common::Platform::getParameters(argc, argv, args); int returnValue = 1; Common::UString keyFile; std::set<Common::UString> files; if (!parseCommandLine(args, returnValue, keyFile, files)) return returnValue; Aurora::KEYWriter keyWriter; std::list<BIFGroup> groups; for (const auto& file : files) { if (file.endsWith(".bif") || file.endsWith(".bzf")) { BIFGroup group; group.name = file; groups.push_back(group); continue; } else { if (groups.empty()) throw Common::Exception("Files have to start with a bif or bzf archive"); groups.back().files.push_back(file); } } for (const auto& group : groups) { std::printf("Packing %s ... \n", group.name.c_str()); Common::WriteFile writeBIFFile(group.name); Common::ScopedPtr<Aurora::KEYDataWriter> dataFile; if (group.name.endsWith(".bzf")) dataFile.reset(new Aurora::BZFWriter(group.files.size(), writeBIFFile)); else dataFile.reset(new Aurora::BIFWriter(group.files.size(), writeBIFFile)); size_t i = 1; for (const auto& file : group.files) { std::printf("\tPacking %u/%u: %s ... ", (uint)i, static_cast<uint>(group.files.size()), file.c_str()); std::fflush(stdout); Common::ReadFile packFile(file); dataFile->add(packFile, TypeMan.getFileType(file)); ++i; std::printf("Done\n"); } keyWriter.addBIF(group.name, group.files, dataFile->size()); } Common::WriteFile writeFile(keyFile); keyWriter.write(writeFile); } catch (...) { Common::exceptionDispatcherError(); } return 0; }