Research Article

Developing a Tile-Based Rendering Method to Improve Rendering Speed of 3D Geospatial Data with HTML5 and WebGL

Algorithm 2

Bin-pack application source code.
(1) function TextureBinPack2D(twidth, theight)
(2)
(3)// Define BinPack Content.
(4)create Content is BinPack2D;
(5)
(6)// Obtain the total number of divided images.
(7)get spiltFaceNum is All count of split face;
(8)
(9)// Image’s Face Search.
(10)for (i = 0 to spiltFaceNum)
(11)ti = texture index of Face;
(12)if(ti>-1 and not contain) // If a texture index exists, it gets the size of the image.
(13)set width = width of Image[ti];
(14)set height = height of Image[ti];
(15)
(16)//Set Image rect and save the image area.
(17)set ss << “box” << ti;
(18)insert Content(ss) into myContent;
(19)Content index = ti;
(20)
(21)// Add it to Image content
(22)insert BinPack2D(myContent, Coord of BinPack2D, size(width, height) of BinPack2D) into Content;
(23)
(24)
(25)
(26)sort Content;
(27)
(28)// Image array declaration for bin-pack
(29)canvasArray = myContent(twidth, theight, 4); //Quarter the image area.
(30)remainder = BinPack2D ContentAccumulator; //Setting remaining space after image placement.
(31)bool success = result of canvasArray(Content, remainder); //Check place an image was successful.
(32)
(33)outputContent = ContentAccumulator of BinpPack2D; //Apply the result after placing the image.
(34)CollectContent = canvasArray(outputContent); //Collect and store image results.
(35)
(36)binpack2d_iterator = BinPack2D vector;
(37)get myContent is binpack2d_iterator;
(38)
(39)// Information of an image in which the area exists.
(40)print “PLACED”;
(41)for (i = start of outputContent to end of outputContent)
(42)set myContent = information of content;
(43)
(44)
(45)// Enter the information of the image with the area.
(46)print (idx++, string of myContent, width of content, height of content,
(47)x of content, y of content, z of content, rotate of content);
(48)
(49)// Information of an image in which the area not exists.
(50)print “NOT PLACED”;
(51)for (i = start of remainder to end of remainder)
(52)set myContent = information of content;
(53)
(54)
(55)//Enter information for an image without a region.
(56)print (string of myContent, width of content, height of content);
(57)