From 4a6d30f8a27c7f2791f8c7a3a439067091b3a6bc Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sat, 29 Oct 2011 00:47:24 -0500 Subject: [PATCH] Add basic wire support rendering for IC2 --- renderdata/ic2-models.txt-disabled | 198 ++++++++++++++++++ .../java/org/dynmap/hdmap/HDBlockModels.java | 89 ++++++-- .../org/dynmap/hdmap/IsoHDPerspective.java | 53 ++++- src/main/resources/models.txt | 10 + 4 files changed, 320 insertions(+), 30 deletions(-) create mode 100644 renderdata/ic2-models.txt-disabled diff --git a/renderdata/ic2-models.txt-disabled b/renderdata/ic2-models.txt-disabled new file mode 100644 index 00000000..1f087700 --- /dev/null +++ b/renderdata/ic2-models.txt-disabled @@ -0,0 +1,198 @@ +# Wire - set render alg +linkmap:id=228,linkalg=5,linkid=223,linkid=225,linkid=226,linkid=227,linkid=228,linkid=233,linkid=237,linkid=246,linkid=250 +# Wire - (data is faked: 1=north,2=east,4=south,8=west) +# Wire - no neighbors +block:id=228,data=0,scale=16 +layer:6,7,8,9 +---------------- +---------------- +---------------- +---------------- +---------------- +---------------- +------****------ +------****------ +------****------ +------****------ +---------------- +---------------- +---------------- +---------------- +---------------- +---------------- +# Wire - just north neighbor +block:id=228,data=1,scale=16 +layer:6,7,8,9 +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +---------------- +---------------- +---------------- +---------------- +---------------- +---------------- +# Wire - just east neighbor +block:id=228,data=2,scale=16 +rotate:id=228,data=1,rot=90 +# Wire - just south neighbor +block:id=228,id=113,data=4,scale=16 +rotate:id=228,data=1,rot=180 +# Wire - just south neighbor +block:id=228,data=8,scale=16 +rotate:id=228,data=1,rot=270 +# Wire - north and east neighbor +block:id=228,data=3,scale=16 +layer:6,7,8,9 +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------********** +------********** +------********** +------********** +---------------- +---------------- +---------------- +---------------- +---------------- +---------------- +# Wire - east and south neighbor +block:id=228,data=6,scale=16 +rotate:id=228,data=3,rot=90 +# Wire - south and west neighbor +block:id=228,data=12,scale=16 +rotate:id=228,data=3,rot=180 +# Wire - west and north neighbor +block:id=228,data=9,scale=16 +rotate:id=228,data=3,rot=270 +# Wire - north and south neighbor +block:id=228,data=5,scale=16 +layer:6,7,8,9 +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +# Wire - east and west neighbor +block:id=228,data=10,scale=16 +rotate:id=228,data=5,rot=90 +# Wire - north, east and south neighbor +block:id=228,data=7,scale=16 +layer:6,7,8,9 +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +------********** +------********** +------********** +------********** +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +# Wire - east, south and west neighbor +block:id=228,data=14,scale=16 +rotate:id=228,data=7,rot=90 +# Wire - south, west and north neighbor +block:id=228,data=13,scale=16 +rotate:id=228,data=7,rot=180 +# Wire - west, north and east neighbor +block:id=228,data=11,scale=16 +rotate:id=228,data=7,rot=270 +# Wire - north, south, east, west neightbors +block:id=228,data=15,scale=16 +layer:6,7,8,9 +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +**************** +**************** +**************** +**************** +------****------ +------****------ +------****------ +------****------ +------****------ +------****------ +# Iron Fence - set render algorithm +linkmap:id=232,linkalg=1 +# Iron Fence - (data is faked: 1=north,2=east,4=south,8=west) +# Iron Fence - no neighbors +block:id=232,data=0,scale=16 +rotate:id=85,data=0,rot=0 +# Iron Fence - just north neighbor +block:id=232,data=1,scale=16 +rotate:id=85,data=1,rot=0 +# Iron Fence - just east neighbor +block:id=232,data=2,scale=16 +rotate:id=232,data=1,rot=90 +# Iron Fence - just south neighbor +block:id=232,data=4,scale=16 +rotate:id=232,data=1,rot=180 +# Iron Fence - just south neighbor +block:id=232,data=8,scale=16 +rotate:id=232,data=1,rot=270 +# Iron Fence - north and east neighbor +block:id=232,data=3,scale=16 +rotate:id=85,data=3,rot=0 +# Iron Fence - east and south neighbor +block:id=232,data=6,scale=16 +rotate:id=232,data=3,rot=90 +# Iron Fence - south and west neighbor +block:id=232,data=12,scale=16 +rotate:id=85,data=3,rot=180 +# Iron Fence - west and north neighbor +block:id=232,data=9,scale=16 +rotate:id=85,data=3,rot=270 +# Iron Fence - north and south neighbor +block:id=232,data=5,scale=16 +rotate:id=85,data=5,rot=0 +# Iron Fence - east and west neighbor +block:id=232,id=113,data=10,scale=16 +rotate:id=232,data=5,rot=90 +# Iron Fence - north, east and south neighbor +block:id=232,data=7,scale=16 +rotate:id=85,data=7,rot=0 +# Iron Fence - east, south and west neighbor +block:id=232,data=14,scale=16 +rotate:id=232,data=7,rot=90 +# Iron Fence - south, west and north neighbor +block:id=232,data=13,scale=16 +rotate:id=232,data=7,rot=180 +# Iron Fence - west, north and east neighbor +block:id=232,data=11,scale=16 +rotate:id=232,data=7,rot=270 +# Iron Fence - north, south, east, west neightbors +block:id=232,data=15,scale=16 +layer:id=232,data=15,rot=0 diff --git a/src/main/java/org/dynmap/hdmap/HDBlockModels.java b/src/main/java/org/dynmap/hdmap/HDBlockModels.java index c0b6edfd..8df14444 100644 --- a/src/main/java/org/dynmap/hdmap/HDBlockModels.java +++ b/src/main/java/org/dynmap/hdmap/HDBlockModels.java @@ -11,6 +11,7 @@ import java.io.InputStreamReader; import java.io.LineNumberReader; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import org.bukkit.Material; import org.dynmap.Log; @@ -25,6 +26,8 @@ public class HDBlockModels { private long blockflags[]; private int nativeres; private HashMap scaledblocks; + private static int linkalg[] = new int[256]; + private static int linkmap[][] = new int[256][]; private static HashMap models_by_id_data = new HashMap(); @@ -49,10 +52,6 @@ public class HDBlockModels { this.databits = databits; this.nativeres = m.nativeres; this.blockflags = m.blockflags; - for(int i = 0; i < 16; i++) { - if((databits & (1< blkids = new ArrayList(); + line = line.substring(8); + String[] args = line.split(","); + List map = null; + int linktype = 0; + for(String a : args) { + String[] av = a.split("="); + if(av.length < 2) continue; + if(av[0].equals("id")) { + blkids.add(Integer.parseInt(av[1])); + } + else if(av[0].equals("linkalg")) { + linktype = Integer.parseInt(av[1]); + } + else if(av[0].equals("linkid")) { + if(map == null) map = new ArrayList(); + map.add(Integer.parseInt(av[1])); + } + } + if(map != null) { + int[] mapids = new int[map.size()]; + for(int i = 0; i < mapids.length; i++) + mapids[i] = map.get(i); + for(Integer bid : blkids) { + linkalg[bid] = linktype; + linkmap[bid] = mapids; + } + } + } else if(line.startsWith("#") || line.startsWith(";")) { } else if(layerbits != 0) { /* If we're working pattern lines */ diff --git a/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java b/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java index 7211038b..a2d24851 100644 --- a/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java +++ b/src/main/java/org/dynmap/hdmap/IsoHDPerspective.java @@ -516,6 +516,38 @@ public class IsoHDPerspective implements HDPerspective { } return blockdata; } + private final boolean containsID(int id, int[] linkids) { + for(int lid: linkids) + if(id == lid) + return true; + return false; + } + private int generateWireBlockData(MapIterator mapiter, int[] linkids) { + int blockdata = 0; + int id; + /* Check north */ + id = mapiter.getBlockTypeIDAt(BlockStep.X_MINUS); + if(containsID(id, linkids)) { + blockdata |= 1; + } + /* Look east */ + id = mapiter.getBlockTypeIDAt(BlockStep.Z_MINUS); + if(containsID(id, linkids)) { + blockdata |= 2; + } + /* Look south */ + id = mapiter.getBlockTypeIDAt(BlockStep.X_PLUS); + if(containsID(id, linkids)) { + blockdata |= 4; + } + /* Look west */ + id = mapiter.getBlockTypeIDAt(BlockStep.Z_PLUS); + if(containsID(id, linkids)) { + blockdata |= 8; + } + return blockdata; + } + private final boolean handleSubModel(short[] model, HDShaderState[] shaderstate, boolean[] shaderdone) { boolean firststep = true; @@ -535,6 +567,11 @@ public class IsoHDPerspective implements HDPerspective { } return false; } + private static final int FENCE_ALGORITHM = 1; + private static final int CHEST_ALGORITHM = 2; + private static final int REDSTONE_ALGORITHM = 3; + private static final int GLASS_IRONFENCE_ALG = 4; + private static final int WIRE_ALGORITHM = 5; /** * Process visit of ray to block */ @@ -547,21 +584,23 @@ public class IsoHDPerspective implements HDPerspective { } else if(nonairhit || (blocktypeid != 0)) { blockdata = mapiter.getBlockData(); - switch(blocktypeid) { - case FENCE_BLKTYPEID: /* Special case for fence - need to fake data so we can render properly */ - case NETHERFENCE_BLKTYPEID: + switch(HDBlockModels.getLinkAlgID(blocktypeid)) { + case FENCE_ALGORITHM: /* Fence algorithm */ blockrenderdata = generateFenceBlockData(mapiter, blocktypeid); break; - case CHEST_BLKTYPEID: /* Special case for chest - need to fake data so we can render */ + case CHEST_ALGORITHM: blockrenderdata = generateChestBlockData(mapiter); break; - case REDSTONE_BLKTYPEID: /* Special case for redstone - fake data for wire pattern */ + case REDSTONE_ALGORITHM: blockrenderdata = generateRedstoneWireBlockData(mapiter); break; - case IRONFENCE_BLKTYPEID: /* Special case for iron fence - fake data for adjacent block info */ - case GLASSPANE_BLKTYPEID: /* Special case for glass pane - fake data for adjacent block info */ + case GLASS_IRONFENCE_ALG: blockrenderdata = generateIronFenceGlassBlockData(mapiter, blocktypeid); break; + case WIRE_ALGORITHM: + blockrenderdata = generateWireBlockData(mapiter, HDBlockModels.getLinkIDs(blocktypeid)); + break; + case 0: default: blockrenderdata = -1; break; diff --git a/src/main/resources/models.txt b/src/main/resources/models.txt index ad8a3ba5..4145df13 100644 --- a/src/main/resources/models.txt +++ b/src/main/resources/models.txt @@ -31,6 +31,8 @@ rotate:id=53,data=0,rot=90 # Nether brick stair - up east block:id=53,id=67,id=108,id=109,id=114,data=3,scale=2 rotate:id=53,data=0,rot=270 +# Chest - set render alg +linkmap:id=54,linkalg=2 # Slab (stone, sandstone, wood, cobblestone) block:id=44,data=*,scale=4 layer:0,1 @@ -173,6 +175,9 @@ rotate:id=50,data=1,rot=90 # Redstone torch off - pointing east block:id=50,id=75,id=76,data=4,scale=16 rotate:id=50,data=1,rot=270 +# Fence - set render algorithm +# Nether brick fence - set render alg +linkmap:id=85,id=113,linkalg=1 # Fence - (data is faked: 1=north,2=east,4=south,8=west) # Fence - no neighbors # Nether Brick Fence @@ -876,6 +881,8 @@ rotate:id=68,data=2,rot=270 # Wall sign - facing south block:id=68,data=5,scale=8 rotate:id=68,data=2,rot=90 +# Redstone - render alg +linkmap:id=55,linkalg=3 # Redstone wire (NSEW) block:id=55,data=0,scale=16 layer:0,1 @@ -1904,6 +1911,9 @@ rotate:id=34,data=2,rot=270 # Piston extension - extended facing west block:id=34,data=5,data=13,scale=8 rotate:id=34,data=2,rot=90 +# Glass pane - render alg +# Iron fence - render alg +linkmap:id=101,id=102,linkalg=4 # Glass pane - no adjacent (0), all adjacent (15) # Iron fence - no adjacent (0), all adjacent (15) block:id=102,id=101,data=0,data=15,scale=16