/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2014 Chuck Ritola
 * Part of the jTRFP.org project
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html
 * 
 * Contributors:
 *     chuck - initial API and implementation
 ******************************************************************************/
package org.jtrfp.trcl.obj;

import org.apache.commons.math3.geometry.euclidean.threed.Vector3D;
import org.jtrfp.trcl.RenderMode;
import org.jtrfp.trcl.Triangle;
import org.jtrfp.trcl.core.TR;
import org.jtrfp.trcl.core.TextureDescription;
import org.jtrfp.trcl.gpu.Model;

public class Sprite2D extends WorldObject2DVisibleEverywhere {

    public Sprite2D(TR tr, double z, double width, double height, TextureDescription tex, boolean useAlpha) {
	super(tr);
	if(tex==null)
	    throw new NullPointerException("Supplied texture intolerably null.");
	final Model m = new Model(false,tr);
	Triangle [] tris = Triangle.quad2Triangles(
		new double[]{-width/2,width/2,width/2,-width/2}, 
		new double[]{-height/2,-height/2,height/2,height/2}, 
		new double[]{z,z,z,z},
		new double[]{0,1,1,0},
		new double[]{0,0,1,1}, tex, RenderMode.DYNAMIC, useAlpha,Vector3D.ZERO,"Sprite2D non-segmented");
	m.addTriangles(tris);
	m.finalizeModel();
	setModel(m);
	setTop(Vector3D.PLUS_J);
	setActive(true);
	setVisible(true);
    }//end constructor
    
    public Sprite2D(TR tr, double z, double width, double height, TextureDescription [] tex, boolean useAlpha){
	super(tr);
	final Model m = new Model(false,tr);
	final int numSegs = tex.length;
	for (int seg = 0; seg < numSegs; seg++) {
	    final double segWidth = width / numSegs;
	    final double x = (-width/2) + segWidth * seg;
	    
	    Triangle[] tris = Triangle.quad2Triangles(new double[] { x,
		    x + segWidth, x + segWidth, x }, new double[] { -height/2, -height/2,
		    height/2, height/2 }, new double[] { z, z, z, z }, new double[] { 0, 1,
		    1, 0 }, new double[] { 0, 0, 1, 1 }, tex[seg],
		    RenderMode.DYNAMIC, Vector3D.ZERO,"Sprite2D "+numSegs+" segments");
	    tris[0].setAlphaBlended(true);
	    tris[1].setAlphaBlended(true);
	    m.addTriangles(tris);
	}// end for(segs)
	setModel(m.finalizeModel());
	setTop(Vector3D.PLUS_J);
	setHeading(Vector3D.PLUS_K);
	setActive(true);
	setVisible(true);
    }//end constructor
}//end Sprite2D

@@ -909,16 +909,62 @@
 ywhere %7B
+%0A    private final TextureDescription texture;
 %0A%0A    pu
@@ -1169,16 +1169,35 @@
 ull.%22);%0A
+%09this.texture=tex;%0A
 %09final M
@@ -1797,24 +1797,136 @@
 %09super(tr);%0A
+%09if(tex==null)%0A%09    throw new NullPointerException(%22Supplied texture intolerably null.%22);%0A%09this.texture=tex%5B0%5D;%0A
 %09final Model
@@ -2709,32 +2709,32 @@
 tVisible(true);%0A
-
     %7D//end const
@@ -2739,16 +2739,135 @@
 structor
+%0A%0A    /**%0A     * @return the texture%0A     */%0A    public TextureDescription getTexture() %7B%0A        return texture;%0A    %7D
 %0A%7D//end 

Add texture getter to Sprite2D.