AtlasExample_iphone_project.zip
__MACOSX
AtlasExample
._.DS_Store
AtlasExample
._.DS_Store
._AtlasExample-Prefix.pch
._ImagePNG.mm
._main.m
en.lproj
._InfoPlist.strings
Shaders
._Shader.fsh
._Shader.vsh
AtlasExampleTests
._AtlasExampleTests.m
._AtlasExampleTests-Prefix.pch
en.lproj
._InfoPlist.strings
AtlasExample
.DS_Store
AtlasExample.xcodeproj
project.pbxproj
project.xcworkspace
contents.xcworkspacedata
xcuserdata
lefty.xcuserdatad
UserInterfaceState.xcuserstate
xcuserdata
lefty.xcuserdatad
xcdebugger
Breakpoints.xcbkptlist
xcschemes
AtlasExample.xcscheme
xcschememanagement.plist
AtlasExample
.DS_Store
AtlasAppDelegate.mm
AtlasExample-Info.plist
AtlasExample-Prefix.pch
EAGLView.mm
en.lproj
InfoPlist.strings
MainWindow.xib
ImagePNG.mm
images0.tga
main.m
Shaders
Shader.fsh
Shader.vsh
AtlasExampleTests
AtlasExampleTests.m
AtlasExampleTests-Info.plist
AtlasExampleTests-Prefix.pch
en.lproj
InfoPlist.strings
AtlasExample_iPhone_project_2.1.zip
._.DS_Store
._.DS_Store
._AtlasExample-Prefix.pch
._ImagePNG.mm
._main.m
._InfoPlist.strings
._Shader.fsh
._Shader.vsh
._AtlasExampleTests.m
._AtlasExampleTests-Prefix.pch
._InfoPlist.strings
.DS_Store
project.pbxproj
contents.xcworkspacedata
UserInterfaceState.xcuserstate
Breakpoints.xcbkptlist
AtlasExample.xcscheme
xcschememanagement.plist
.DS_Store
AtlasAppDelegate.mm
AtlasExample-Info.plist
AtlasExample-Prefix.pch
EAGLView.mm
InfoPlist.strings
MainWindow.xib
ImagePNG.mm
imagesNelly0.tga
main.m
Shader.fsh
Shader.vsh
AtlasExampleTests.m
AtlasExampleTests-Info.plist
AtlasExampleTests-Prefix.pch
InfoPlist.strings
AtlasMaker.zip
AtlasMaker
.classpath
.project
bin
icon.png
images
icon.png
output.png
settings.png
output.png
settings.png
src
AtlasMaker_jar.zip
AtlasMaker.jar
AtlasMaker_jar_2.0.zip
AtlasMaker.jar
AtlasMaker_jar_2.1.zip
AtlasMaker.jar
AtlasMaker_jar_2.2.1.zip
AtlasMaker.jar
AtlasMaker_jar_2.2.zip
AtlasMaker.jar
AtlasMaker_source.2.2.1.zip
.classpath
.project
.settings
org.eclipse.jdt.core.prefs
atlasMaker.properties
icon.png
icon.png
settings.png
settings.png
AtlasMaker_source.zip
.classpath
.project
icon.png
icon.png
output.png
settings.png
output.png
settings.png
AtlasMaker_source_2.0.zip
.classpath
.project
atlasMaker.properties
icon.png
icon.png
settings.png
settings.png
AtlasMaker_source_2.1.zip
.classpath
.project
org.eclipse.jdt.core.prefs
atlasMaker.properties
icon.png
icon.png
settings.png
settings.png
AtlasMaker_source_2.2.zip
.classpath
.project
org.eclipse.jdt.core.prefs
icon.png
icon.png
settings.png
settings.png
|
import java.util.ArrayList;
import java.util.Collections;
public class BinPacker
{
private TreeNode treeNode;
private TexturePiece texturePiece;
public TexturePiece getTexturePiece()
{
return texturePiece;
}
public BinPacker(int width, int height)
{
treeNode = new TreeNode(0, 0, width, height, "");
texturePiece = new TexturePiece(width, height);
}
public boolean add(AtlasImage image)
{
boolean added = treeNode.add(image);
if (added)
texturePiece.add(image);
return added;
}
public void pack(ArrayList<AtlasImage> listImage)
{
int ixImage;
for (ixImage = listImage.size()-1; ixImage >= 0; ixImage--)
{
if (!add(listImage.get(ixImage)))
return;
listImage.remove(ixImage);
}
}
public void resize(int width, int height, ArrayList<AtlasImage> listImage)
{
// puts images removed back on the list
texturePiece.remove(listImage);
// need to resort, because they may have been put in wrong order
Collections.sort(listImage, new CompareArea());
// resize resets everything
treeNode.resize(width, height);
texturePiece.resize(width, height);
}
}
|
By viewing downloads associated with this article you agree to the Terms of use and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.