<commit_before>package org.jtrfp.trcl.obj;

import java.awt.Dimension;

import org.jtrfp.trcl.Model;
import org.jtrfp.trcl.RenderMode;
import org.jtrfp.trcl.TextureDescription;
import org.jtrfp.trcl.Triangle;
import org.jtrfp.trcl.core.TR;


public class BillboardSprite extends WorldObject
	{
	Dimension dim;
	
	public BillboardSprite(TR tr){super(tr);}
	@Override
	protected void recalculateTransRotMBuffer()
		{
		this.setHeading(getTr().getRenderer().getCamera().getLookAtVector().negate());
		this.setTop(getTr().getRenderer().getCamera().getUpVector());
		super.recalculateTransRotMBuffer();
		}//end recalculateTransRotMBuffer()
	
	public void setBillboardSize(Dimension dim)
		{this.dim=dim;}
	public Dimension getBillboardSize(){return this.dim;}
	
	public void setTexture(TextureDescription desc, boolean useAlpha)
		{
		if(dim==null)throw new NullPointerException("Billboard size must be non-null. (did you forget to set it?)");
		Triangle[] tris= Triangle.quad2Triangles(
				new double[]{-.5*dim.getWidth(),.5*dim.getWidth(),.5*dim.getWidth(),-.5*dim.getWidth()}, //X
				new double[]{-.5*dim.getHeight(),-.5*dim.getHeight(),.5*dim.getHeight(),.5*dim.getHeight()}, 
				new double[]{0,0,0,0}, 
				new double[]{0,1,1,0}, //U
				new double[]{0,0,1,1}, 
				desc, 
				RenderMode.DYNAMIC);
		tris[0].setAlphaBlended(useAlpha);
		tris[1].setAlphaBlended(useAlpha);
		Model m = new Model(false);
		m.addTriangles(tris);
		setModel(m.finalizeModel());
		}
	}//end BillboardSprite
<commit_msg>Added support for 2d rotation around camera lookAt vector<commit_after>package org.jtrfp.trcl.obj;

import java.awt.Dimension;

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


public class BillboardSprite extends WorldObject
{
	private Dimension dim;
	private double rotation=0;
	
	public BillboardSprite(TR tr){super(tr);}
	@Override
	protected void recalculateTransRotMBuffer(){
	    	final Camera camera = getTr().getRenderer().getCamera();
	    	final Vector3D cLookAt = camera.getLookAtVector();
	    	final Rotation rot = new Rotation(cLookAt,rotation);
		this.setHeading(rot.applyTo(cLookAt.negate()));
		this.setTop(rot.applyTo(camera.getUpVector()));
		super.recalculateTransRotMBuffer();
		}//end recalculateTransRotMBuffer()
	
	public void setBillboardSize(Dimension dim)
		{this.dim=dim;}
	public Dimension getBillboardSize(){return this.dim;}
	
	public void setTexture(TextureDescription desc, boolean useAlpha)
		{
		if(dim==null)throw new NullPointerException("Billboard size must be non-null. (did you forget to set it?)");
		Triangle[] tris= Triangle.quad2Triangles(
				new double[]{-.5*dim.getWidth(),.5*dim.getWidth(),.5*dim.getWidth(),-.5*dim.getWidth()}, //X
				new double[]{-.5*dim.getHeight(),-.5*dim.getHeight(),.5*dim.getHeight(),.5*dim.getHeight()}, 
				new double[]{0,0,0,0}, 
				new double[]{0,1,1,0}, //U
				new double[]{0,0,1,1}, 
				desc, 
				RenderMode.DYNAMIC);
		tris[0].setAlphaBlended(useAlpha);
		tris[1].setAlphaBlended(useAlpha);
		Model m = new Model(false);
		m.addTriangles(tris);
		setModel(m.finalizeModel());
		}
	
	public void setRotation(double angle){
	    rotation=angle;
	}
}//end BillboardSprite

{'fraction_non_alphanumeric': 0.1519721577726218, 'fraction_numerical': 0.015081206496519721, 'mean_word_length': 5.072183098591549, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '2886979', 'n_tokens_mistral': 1303, 'n_tokens_neox': 1207, 'n_words': 212}