public Sprite( BufferedImage img, Controller c, int width, int height, TextureHolder th, int currenttexid, Vector2f pos) { TextureUtils util = new TextureUtils(); imgdata = util.loadtexture(img); parent = c; any = true; this.th = th; texture = img; modelmatrix.translate(pos); this.currenttexid = currenttexid; this.width = width; this.height = height; this.pos = pos; datafb = getData(this.pos, width, height, currenttexid); indices = getIndices(0); }
public Sprite(BufferedImage img, Controller c, int width, int height, Vector2f pos) { TextureUtils util = new TextureUtils(); imgdata = util.loadtexture(img); parent = c; any = true; texture = img; setPos(0.0f, -7.0f); modelmatrix.translate(pos); this.width = width; this.height = height; this.pos = pos; datafb = getData(this.pos, width, height); indices = getIndices(0); }
public int finish(int vboid, int vaoid) { this.vboID = vboid; this.vaoID = vaoid; TextureUtils util = new TextureUtils(); return this.textureid = util.binddata(texture, imgdata); }
public void addTexture(BufferedImage img, Vector2f[] v) { subimages.add(img); coordinates.add(v[0]); coordinates.add(v[1]); coordinates.add(v[2]); Vector2f drawloc = new Vector2f(); for (boolean done = false; !done; ) { try { drawloc = tg.nearestSpace(img); done = true; } catch (Exception e) { if (e.getLocalizedMessage() == "enlarge") { atlas = new BufferedImage( atlas.getWidth() * 2, atlas.getHeight() * 2, BufferedImage.TYPE_INT_ARGB); tg.enlarge(atlas); for (int i = 0; i < drawingcoords.size(); i++) { tg.useup(drawingcoords.get(i), subimages.get(i)); } } } } drawingcoords.add(drawloc); atlasgraphics = atlas.getGraphics(); atlasgraphics.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f)); atlasgraphics.fillRect(0, 0, atlas.getWidth(), atlas.getHeight()); for (int i = 0; i < drawingcoords.size(); i++) { atlasgraphics.drawImage( (Image) subimages.get(i), (int) drawingcoords.get(i).x, (int) drawingcoords.get(i).y, null); } realtexcoods.clear(); for (int i = 0; i < subimages.size(); i++) { Vector2f vec = new Vector2f(); vec = converttoimagesizes( coordinates.get(i * 3), drawingcoords.get(i), subimages.get(i), atlas); realtexcoods.add(vec); vec = converttoimagesizes( coordinates.get((i * 3) + 1), drawingcoords.get(i), subimages.get(i), atlas); realtexcoods.add(vec); vec = converttoimagesizes( coordinates.get((i * 3) + 2), drawingcoords.get(i), subimages.get(i), atlas); realtexcoods.add(vec); } tg.useup(drawloc, img); TextureUtils util = new TextureUtils(); util.binddata(atlas, texID); // File outputfile = new File("saved @ " + this.hashCode() + ".png"); // try { // ImageIO.write(atlas, "png", outputfile); // } catch (IOException e) { // e.printStackTrace(); // } }