<commit_before>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2014 <NAME>
 * 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.TRFutureTask;
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);
	final Model m = new Model(false,tr);
	Triangle [] tris = Triangle.quad2Triangles(
		new double[]{-width,width,width,-width}, 
		new double[]{-height,-height,height,height}, 
		new double[]{z,z,z,z},
		new double[]{0,1,1,0},
		new double[]{0,0,1,1}, tex, RenderMode.DYNAMIC, useAlpha,Vector3D.MINUS_K,"Sprite2D");
	m.addTriangles(tris);
	m.finalizeModel();
	setModel(m);
	setTop(Vector3D.PLUS_J);
	setActive(true);
	setVisible(true);
    }

}<commit_msg>Added horizontal non-square (segmented texture) support to Sprite2D.<commit_after>/*******************************************************************************
 * This file is part of TERMINAL RECALL
 * Copyright (c) 2012-2014 <NAME>
 * 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.TRFutureTask;
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);
	final Model m = new Model(false,tr);
	Triangle [] tris = Triangle.quad2Triangles(
		new double[]{-width,width,width,-width}, 
		new double[]{-height,-height,height,height}, 
		new double[]{z,z,z,z},
		new double[]{0,1,1,0},
		new double[]{0,0,1,1}, tex, RenderMode.DYNAMIC, useAlpha,Vector3D.MINUS_K,"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.MINUS_K,"Sprite2D "+numSegs+" segments");
	    tris[0].setAlphaBlended(true);
	    tris[1].setAlphaBlended(true);
	    m.addTriangles(tris);
	}// end for(segs)
	setModel(m.finalizeModel());
    }//end constructor
}//end Sprite2D
{'fraction_non_alphanumeric': 0.1993584998766346, 'fraction_numerical': 0.018751542067604245, 'mean_word_length': 4.742209631728045, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3605', 'n_tokens_mistral': 1385, 'n_tokens_neox': 1310, 'n_words': 330}