|
3 | 3 | import cwlib.enums.*; |
4 | 4 | import cwlib.gl.jobs.DecalBaker; |
5 | 5 | import cwlib.gl.jobs.MaterialBaker; |
| 6 | +import cwlib.io.Resource; |
6 | 7 | import cwlib.io.streams.MemoryOutputStream; |
7 | 8 | import cwlib.resources.*; |
8 | 9 | import cwlib.singleton.ResourceSystem; |
|
21 | 22 | import cwlib.types.archives.SaveArchive; |
22 | 23 | import cwlib.types.data.ResourceDescriptor; |
23 | 24 | import cwlib.types.databases.FileDB; |
| 25 | +import cwlib.types.databases.FileDBRow; |
24 | 26 | import cwlib.types.databases.FileEntry; |
25 | 27 | import de.javagl.jgltf.impl.v2.Image; |
26 | 28 | import de.javagl.jgltf.impl.v2.*; |
@@ -387,7 +389,7 @@ else if (specular.isSimpleMultiply(gmat)) |
387 | 389 | material.addExtensions("KHR_materials_specular", spec); |
388 | 390 | } |
389 | 391 |
|
390 | | - MaterialBox glow = gmat.getBoxConnectedToPort(output, BrdfPort.GLOW); |
| 392 | + MaterialBox glow = gmat.getBoxConnectedToPort(output, BrdfPort.SELF_ILLUMINATION); |
391 | 393 | if (glow != null) |
392 | 394 | { |
393 | 395 | material.setEmissiveFactor(new float[] { 1.0f, 1.0f, 1.0f }); |
@@ -425,7 +427,7 @@ else if (glow.isTexture()) |
425 | 427 | TextureInfo info = new TextureInfo(); |
426 | 428 | System.out.println("Baking " + name + " glow texture"); |
427 | 429 | byte[] png = new MaterialBaker(mesh, gmat, gfxMaterialDescriptor, |
428 | | - materialTransform, BrdfPort.GLOW, 0).BakeToPNG(); |
| 430 | + materialTransform, BrdfPort.SELF_ILLUMINATION, 0).BakeToPNG(); |
429 | 431 | info.setIndex(registerTexture(name + "_baked.glow", png)); |
430 | 432 | material.setEmissiveTexture(info); |
431 | 433 | } |
@@ -473,7 +475,7 @@ public int registerMaterial(RMesh mesh, Vector4f materialTransform, |
473 | 475 |
|
474 | 476 |
|
475 | 477 | boolean isAlphaClip = ((gmat.flags & GfxMaterialFlags.ALPHA_CLIP) != 0); |
476 | | - boolean hasAlphaNode = gmat.getBoxConnectedToPort(output, BrdfPort.ALPHA_CLIP) != null; |
| 478 | + boolean hasAlphaNode = gmat.getBoxConnectedToPort(output, BrdfPort.OPACITY) != null; |
477 | 479 | boolean isAlphaBlend = gmat.alphaMode != 0; |
478 | 480 |
|
479 | 481 | if (isAlphaBlend && !isAlphaClip) material.setAlphaMode(AlphaMode.BLEND); |
@@ -634,7 +636,7 @@ else if (specular.isSimpleMultiply(gmat)) |
634 | 636 | material.addExtensions("KHR_materials_specular", spec); |
635 | 637 | } |
636 | 638 |
|
637 | | - MaterialBox glow = gmat.getBoxConnectedToPort(output, BrdfPort.GLOW); |
| 639 | + MaterialBox glow = gmat.getBoxConnectedToPort(output, BrdfPort.SELF_ILLUMINATION); |
638 | 640 | if (glow != null) |
639 | 641 | { |
640 | 642 | material.setEmissiveFactor(new float[] { 1.0f, 1.0f, 1.0f }); |
@@ -673,7 +675,7 @@ else if (glow.isTexture()) |
673 | 675 | TextureInfo info = new TextureInfo(); |
674 | 676 | System.out.println("Baking " + name + " glow texture"); |
675 | 677 | byte[] png = new MaterialBaker(mesh, gmat, descriptor, materialTransform, |
676 | | - BrdfPort.GLOW, 0).BakeToPNG(); |
| 678 | + BrdfPort.SELF_ILLUMINATION, 0).BakeToPNG(); |
677 | 679 | info.setIndex(registerTexture(name + "_baked.glow", png)); |
678 | 680 | material.setEmissiveTexture(info); |
679 | 681 | } |
@@ -1547,5 +1549,49 @@ static class KHRMaterialsSpecular |
1547 | 1549 | { |
1548 | 1550 | public float[] specularColorFactor; |
1549 | 1551 | public TextureInfo specularColorTexture; |
| 1552 | + } |
| 1553 | + |
| 1554 | + public static void main(String[] args) |
| 1555 | + { |
| 1556 | + ResourceSystem.GUI_MODE = false; |
| 1557 | + |
| 1558 | + FileDB database = new FileDB("E:\\emu\\rpcs3\\dev_hdd0\\game\\LBP1DEBUG\\USRDIR\\gamedata\\alear\\sync\\alrs.map"); |
| 1559 | + |
| 1560 | + ResourceSystem.getDatabases().add(database); |
| 1561 | + ResourceSystem.getDatabases().add(new FileDB("E:\\emu\\rpcs3\\dev_hdd0\\game\\LBP1DEBUG\\USRDIR\\output\\brg_patch.map")); |
| 1562 | + ResourceSystem.getDatabases().add(new FileDB("E:\\emu\\rpcs3\\dev_hdd0\\game\\LBP1DEBUG\\USRDIR\\output\\blurayguids.map")); |
| 1563 | + ResourceSystem.getArchives().add(new FileArchive("E:\\\\emu\\\\rpcs3\\\\dev_hdd0\\\\game\\\\LBP1DEBUG\\\\USRDIR\\\\gamedata\\\\alear\\\\sync\\\\alrs.farc")); |
| 1564 | + ResourceSystem.getArchives().add(new FileArchive("E:\\\\emu\\\\rpcs3\\\\dev_hdd0\\\\game\\\\LBP1DEBUG\\\\USRDIR\\\\data.farc")); |
| 1565 | + |
| 1566 | + List<String> fails = new ArrayList<>(); |
| 1567 | + |
| 1568 | + for (FileDBRow row : database) |
| 1569 | + { |
| 1570 | + if (!row.getPath().endsWith(".plan")) continue; |
| 1571 | + RPlan plan = ResourceSystem.load(new ResourceDescriptor(row.getGUID(), ResourceType.PLAN), RPlan.class); |
| 1572 | + if (plan == null) continue; |
| 1573 | + if (!plan.inventoryData.type.contains(InventoryObjectType.BACKGROUND)) continue; |
| 1574 | + |
| 1575 | + try |
| 1576 | + { |
| 1577 | + SceneExporter exporter = new SceneExporter(); |
| 1578 | + exporter.registerPlan(plan); |
| 1579 | + exporter.export("C:/Users/Aidan/Desktop/out/" + row.getName().replace(".plan", ".glb")); |
| 1580 | + } |
| 1581 | + catch (Exception ex) |
| 1582 | + { |
| 1583 | + fails.add(row.getPath()); |
| 1584 | + continue; |
| 1585 | + } |
| 1586 | + } |
| 1587 | + |
| 1588 | + System.out.println("done"); |
| 1589 | + System.out.println("fails:"); |
| 1590 | + for (String fail : fails) |
| 1591 | + System.out.println("\t" + fail); |
| 1592 | + |
| 1593 | + |
| 1594 | + |
| 1595 | + |
1550 | 1596 | } |
1551 | 1597 | } |
0 commit comments