Search in sources :

Example 1 with TextureManager

use of net.runelite.cache.TextureManager in project runelite by runelite.

the class ObjExporterTest method testExport.

@Test
@Ignore
public void testExport() throws Exception {
    try (Store store = new Store(StoreLocation.LOCATION)) {
        store.load();
        TextureManager tm = new TextureManager(store);
        tm.load();
        ModelLoader loader = new ModelLoader();
        ModelDefinition model = loader.load(9638, Files.readAllBytes(new File("D:\\rs\\07\\cache\\models\\9638.model").toPath()));
        ObjExporter exporter = new ObjExporter(tm, model);
        try (PrintWriter objWriter = new PrintWriter(new FileWriter(new File("D:\\rs\\07\\temp\\9638.obj")));
            PrintWriter mtlWriter = new PrintWriter(new FileWriter(new File("D:\\rs\\07\\temp\\9638.mtl")))) {
            exporter.export(objWriter, mtlWriter);
        }
    }
}
Also used : TextureManager(net.runelite.cache.TextureManager) ModelLoader(net.runelite.cache.definitions.loaders.ModelLoader) FileWriter(java.io.FileWriter) ModelDefinition(net.runelite.cache.definitions.ModelDefinition) Store(net.runelite.cache.fs.Store) File(java.io.File) PrintWriter(java.io.PrintWriter) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 2 with TextureManager

use of net.runelite.cache.TextureManager in project runelite by runelite.

the class ItemSpriteFactoryTest method test.

@Test
@Ignore
public void test() throws IOException {
    File base = StoreLocation.LOCATION, outDir = folder.newFolder();
    int count = 0;
    try (Store store = new Store(base)) {
        store.load();
        ItemManager itemManager = new ItemManager(store);
        itemManager.load();
        ModelProvider modelProvider = new ModelProvider() {

            @Override
            public ModelDefinition provide(int modelId) throws IOException {
                Index models = store.getIndex(IndexType.MODELS);
                Archive archive = models.getArchive(modelId);
                byte[] data = archive.decompress(store.getStorage().loadArchive(archive));
                ModelDefinition inventoryModel = new ModelLoader().load(modelId, data);
                return inventoryModel;
            }
        };
        SpriteManager spriteManager = new SpriteManager(store);
        spriteManager.load();
        TextureManager textureManager = new TextureManager(store);
        textureManager.load();
        for (ItemDefinition itemDef : itemManager.getItems()) {
            if (itemDef.name == null || itemDef.name.equalsIgnoreCase("null")) {
                continue;
            }
            try {
                BufferedImage sprite = ItemSpriteFactory.createSprite(itemManager, modelProvider, spriteManager, textureManager, itemDef.id, 1, 1, 3153952, false);
                File out = new File(outDir, itemDef.id + ".png");
                BufferedImage img = sprite;
                ImageIO.write(img, "PNG", out);
                ++count;
            } catch (Exception ex) {
                log.warn("error dumping item {}", itemDef.id, ex);
            }
        }
    }
    log.info("Dumped {} item images to {}", count, outDir);
}
Also used : Archive(net.runelite.cache.fs.Archive) ItemManager(net.runelite.cache.ItemManager) ModelProvider(net.runelite.cache.definitions.providers.ModelProvider) ItemDefinition(net.runelite.cache.definitions.ItemDefinition) Store(net.runelite.cache.fs.Store) Index(net.runelite.cache.fs.Index) SpriteManager(net.runelite.cache.SpriteManager) BufferedImage(java.awt.image.BufferedImage) IOException(java.io.IOException) ModelLoader(net.runelite.cache.definitions.loaders.ModelLoader) TextureManager(net.runelite.cache.TextureManager) ModelDefinition(net.runelite.cache.definitions.ModelDefinition) File(java.io.File) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

File (java.io.File)2 TextureManager (net.runelite.cache.TextureManager)2 ModelDefinition (net.runelite.cache.definitions.ModelDefinition)2 ModelLoader (net.runelite.cache.definitions.loaders.ModelLoader)2 Store (net.runelite.cache.fs.Store)2 Ignore (org.junit.Ignore)2 Test (org.junit.Test)2 BufferedImage (java.awt.image.BufferedImage)1 FileWriter (java.io.FileWriter)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 ItemManager (net.runelite.cache.ItemManager)1 SpriteManager (net.runelite.cache.SpriteManager)1 ItemDefinition (net.runelite.cache.definitions.ItemDefinition)1 ModelProvider (net.runelite.cache.definitions.providers.ModelProvider)1 Archive (net.runelite.cache.fs.Archive)1 Index (net.runelite.cache.fs.Index)1