<commit_before>package Diffraction;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.vecmath.Matrix4f;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
import jrtr.Light;
import jrtr.RenderContext;
import jrtr.Shader;
import jrtr.Shape;
import jrtr.Texture;
import Constants.ShaderPaths;
import Materials.Material;
import SceneGraph.GraphSceneManager;
import SceneGraph.INode;
import SceneGraph.LightNode;
import SceneGraph.ShapeNode;
import SceneGraph.TransformGroup;
import ShaderLogic.DefaultShaderTask;
import ShaderLogic.DiffractionShaderTask;
import ShaderLogic.ExpTaylorShaderTask;
import ShaderLogic.MultiTexturesTAShaderTask;
import ShaderLogic.MultiTexturesTaylorShaderTask;
import ShaderLogic.ShaderTask;
import ShaderLogic.Task3ShaderTask;

public class DiffractionSceneGraphFabricator {
	private GraphSceneManager sceneManager;
	private RenderContext renderContext;
	private INode root;
	private ShaderTask activeShaderTask;
	private Shape diffDice;
	private Shape diffPlane;
	private Matrix4f diffDiceIMat;
	private Matrix4f diffPlaneIMat;
    private Material mat;

    private Texture[] textures = new Texture[2624];
	private Light lightSource1;
	private float trackDistance = 2.5f;
	private TransformGroup rootGroup;
	
	String extension = ".bmp";
	// stam 4
	// grid 9
	// taylor 10
	// experimental: adaptive taylor series 11
	private int version = 10;

	
	
	private boolean hasVectorfield = true;
	private boolean isPlane = true;

	public DiffractionSceneGraphFabricator(GraphSceneManager sceneManager, RenderContext renderContext){
		this.sceneManager = sceneManager;
		this.renderContext = renderContext;
		setUpShaderTask();
		setUpMaterials();
		setUpShapes();
		setUpSceneGraph();
		setUpLight();
		setUpCamera(false);
	}
	
	private void setUpShaderTask(){

		if(version == 9){
			activeShaderTask = new MultiTexturesTAShaderTask();
		}else if(version == 10){
			activeShaderTask = new MultiTexturesTaylorShaderTask();
		}else if(version == 11){
			activeShaderTask = new ExpTaylorShaderTask();
		}else if(version == 4){
		    activeShaderTask = new DiffractionShaderTask();
		}
	}
	
	private void setUpMaterials(){
		mat = new Material();
		mat.setMaterialColor(new Vector3f(0, 0f, 0f));
		mat.setShinnyCoefficient(new Vector3f(0f, 0f, 1f));
		mat.setAmbientCoefficient(new Vector3f(0.0f, 0.0f, 1.0f));
		mat.setPhongExponent(64f);
		mat.setTrackDistance(trackDistance);
		
		
		mat.setLayerCount(108);
		if(version == 10 || version == 11) mat.setLayerCount(62);
		
		Shader shader = renderContext.makeShader();
		try {
			
			if(version==1){
	
			}else if(version == 4){
				shader.load(ShaderPaths.stamVert.toString(), ShaderPaths.stamFrag.toString());
					
			}else if(version == 9){
//				shader.load(ShaderPaths.grid_1d_Vert.toString(), ShaderPaths.grid_1d_Frag.toString());|
//				shader.load(ShaderPaths.grid_1d_Vert.toString(), ShaderPaths.grid_1d_Frag.toString());
				//shader.load(ShaderPaths.grid_2d_Vert.toString(), ShaderPaths.grid_2d_Frag.toString());
//				shader.load(ShaderPaths.grid_T_1dVert.toString(), ShaderPaths.grid_T_1dFrag.toString());
				shader.load(ShaderPaths.grid_T_2dVert.toString(), ShaderPaths.grid_T_2dFrag.toString());
			}else if(version == 10){
				
//				shader.load(ShaderPaths.taylor_1d_Vert.toString(), ShaderPaths.taylor_1d_Frag.toString());
//				shader.load(ShaderPaths.taylor_2d_Vert.toString(), ShaderPaths.taylor_2d_Frag.toString());
//				shader.load(ShaderPaths.taylor_T_1d_Vert.toString(), ShaderPaths.taylor_T_1d_Frag.toString());
				shader.load(ShaderPaths.taylor_T_2d_Vert.toString(), ShaderPaths.taylor_T_2d_Frag.toString());
				
			}else if(version == 11){
				shader.load(ShaderPaths.expTaylor_2d_Vert.toString(), ShaderPaths.expTaylor_2d_Frag.toString());
			}
			

		} catch (Exception e) {}
		
		mat.setShader(shader);
		
		String samples = null;
		String extrema = null;
		
		if(version == 9 || version == 10){
			if(version==1){

				
			// using bmp rgb	
			}else if(version == 9){
				// basis
//				samples = "../jrtr/textures/sampleX/rgb1/";;
//				extrema = "../jrtr/textures/sampleX/rgb1/extrema.txt";;
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/rgb1/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/rgb1/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/rgb1/weights.txt"));
//				
				
				
//				samples = "../jrtr/textures/sampleX/milestone/1dw10/";
//				extrema = "../jrtr/textures/sampleX/milestone/1dw10/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/1dw10/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/1dw10/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/1dw10/weights.txt"));
				
				// basis comparision
				samples = "../jrtr/textures/sampleX/milestone/1dw20/";
				extrema = "../jrtr/textures/sampleX/milestone/1dw20/extrema.txt";
				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/1dw20/kvalues.txt"));
				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/1dw20/globals.txt"));
				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/1dw20/weights.txt"));
//				
				
				
//				samples = "../jrtr/textures/sampleX/2dStam_1/";
//				extrema = "../jrtr/textures/sampleX/2dStam_1/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/2dStam_1/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/2dStam_1/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/2dStam_1/weights.txt"));
				

				
				
//				samples = "../jrtr/textures/sampleX/milestone/1dw30/";
//				extrema = "../jrtr/textures/sampleX/milestone/1dw30/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/1dw30/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/1dw30/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/1dw30/weights.txt"));
				
				
//				samples = "../jrtr/textures/sampleX/milestone/1dspec/";
//				extrema = "../jrtr/textures/sampleX/milestone/1dspec/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/1dspec/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/1dspec/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/1dspec/weights.txt"));
				
				
//				samples = "../jrtr/textures/sampleX/milestone/tri/";
//				extrema = "../jrtr/textures/sampleX/milestone/tri/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/tri/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/tri/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/tri/weights.txt"));
				
				
//				samples = "../jrtr/textures/sampleX/milestone/sin/";
//				extrema = "../jrtr/textures/sampleX/milestone/sin/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/sin/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/sin/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/sin/weights.txt"));
				
//				samples = "../jrtr/textures/sampleX/milestone/crossw20/";
//				extrema = "../jrtr/textures/sampleX/milestone/crossw20/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/crossw20/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/crossw20/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/crossw20/weights.txt"));
				
//				samples = "../jrtr/textures/sampleX/milestone/C/";
//				extrema = "../jrtr/textures/sampleX/milestone/C/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/C/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/C/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/C/weights.txt"));
				
				
//				samples = "../jrtr/textures/sampleX/milestone/cos/";
//				extrema = "../jrtr/textures/sampleX/milestone/cos/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/cos/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/cos/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/cos/weights.txt"));
				

				
//				samples = "../jrtr/textures/sampleX/milestone/pew/";
//				extrema = "../jrtr/textures/sampleX/milestone/pew/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/pew/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/pew/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/pew/weights.txt"));

				String s_name1 = "1dStam";
				String s_name2 = "2dStam";
				String s_name3 = "blaze";
				String s_name4 = "cos";
				String s_name = s_name1;
				samples = "../jrtr/textures/sampleX/padded/"+ s_name +"/";
				extrema = "../jrtr/textures/sampleX/padded/"+ s_name +"/extrema.txt";
				mat.setKValues(loadKValues("../jrtr/textures/sampleX/padded/"+ s_name +"/kvalues.txt"));
				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/padded/"+ s_name +"/globals.txt"));
				mat.setWeights(readWeights("../jrtr/textures/sampleX/padded/"+ s_name +"/weights.txt"));

//				
				
//				samples = "../jrtr/textures/sampleX/milestone/blaze/";
//				extrema = "../jrtr/textures/sampleX/milestone/blaze/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/blaze/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/blaze/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/blaze/weights.txt"));
				
			}else if(version == 10){
//				samples = "../jrtr/textures/sampleX/taylor/w10/";
//				extrema = "../jrtr/textures/sampleX/taylor/w10/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/w10/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/w10/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/w10/weights.txt"));
//				
//				samples = "../jrtr/textures/sampleX/taylor/w20/";
//				extrema = "../jrtr/textures/sampleX/taylor/w20/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/w20/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/w20/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/w20/weights.txt"));
				
				samples = "../jrtr/textures/sampleX/taylor/pewpew/";
				extrema = "../jrtr/textures/sampleX/taylor/pewpew/extrema.txt";
				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/pewpew/kvalues.txt"));
				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/pewpew/globals.txt"));
				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/pewpew/weights.txt"));
				
//				samples = "../jrtr/textures/sampleX/taylor/newA/";
//				extrema = "../jrtr/textures/sampleX/taylor/newA/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/newA/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/newA/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/newA/weights.txt"));
//				
//				samples = "../jrtr/textures/sampleX/taylor/w30/";
//				extrema = "../jrtr/textures/sampleX/taylor/w30/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/w30/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/w30/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/w30/weights.txt"));
//				
//				samples = "../jrtr/textures/sampleX/taylor/cos/";
//				extrema = "../jrtr/textures/sampleX/taylor/cos/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/cos/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/cos/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/cos/weights.txt"));
//				
//				samples = "../jrtr/textures/sampleX/taylor/blaze/";
//				extrema = "../jrtr/textures/sampleX/taylor/blaze/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/blaze/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/blaze/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/blaze/weights.txt"));
				
			}else if(version == 11){
				// TODO add us
			}
			
			if(version == 10) loadTaylorPatches(samples);
			else loadPatches2(samples, false, true);
			
			mat.setHeightfieldFactors(loadScalingConstants(extrema));
		}

	}
	
	// TODO again check this method - for santy's sake!!!
	private void loadTaylorPatches(String basisPath){
		String path = basisPath;
		String ext = ".bmp";
		int counter = 0;<commit_msg>fabricator and engine are now correctly set up for adaptive taylor series approach<commit_after>package Diffraction;

import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import javax.vecmath.Matrix4f;
import javax.vecmath.Point3f;
import javax.vecmath.Vector3f;
import javax.vecmath.Vector4f;
import jrtr.Light;
import jrtr.RenderContext;
import jrtr.Shader;
import jrtr.Shape;
import jrtr.Texture;
import Constants.ShaderPaths;
import Materials.Material;
import SceneGraph.GraphSceneManager;
import SceneGraph.INode;
import SceneGraph.LightNode;
import SceneGraph.ShapeNode;
import SceneGraph.TransformGroup;
import ShaderLogic.DefaultShaderTask;
import ShaderLogic.DiffractionShaderTask;
import ShaderLogic.ExpTaylorShaderTask;
import ShaderLogic.MultiTexturesTAShaderTask;
import ShaderLogic.MultiTexturesTaylorShaderTask;
import ShaderLogic.ShaderTask;
import ShaderLogic.Task3ShaderTask;

public class DiffractionSceneGraphFabricator {
	private GraphSceneManager sceneManager;
	private RenderContext renderContext;
	private INode root;
	private ShaderTask activeShaderTask;
	private Shape diffDice;
	private Shape diffPlane;
	private Matrix4f diffDiceIMat;
	private Matrix4f diffPlaneIMat;
    private Material mat;

    private Texture[] textures = new Texture[2624];
	private Light lightSource1;
	private float trackDistance = 2.5f;
	private TransformGroup rootGroup;
	
	String extension = ".bmp";
	// stam 4
	// grid 9
	// taylor 10
	// experimental: adaptive taylor series 11
	private int version = 11;

	
	
	private boolean hasVectorfield = true;
	private boolean isPlane = true;

	public DiffractionSceneGraphFabricator(GraphSceneManager sceneManager, RenderContext renderContext){
		this.sceneManager = sceneManager;
		this.renderContext = renderContext;
		setUpShaderTask();
		setUpMaterials();
		setUpShapes();
		setUpSceneGraph();
		setUpLight();
		setUpCamera(false);
	}
	
	private void setUpShaderTask(){

		if(version == 9){
			activeShaderTask = new MultiTexturesTAShaderTask();
		}else if(version == 10){
			activeShaderTask = new MultiTexturesTaylorShaderTask();
		}else if(version == 11){
			activeShaderTask = new ExpTaylorShaderTask();
		}else if(version == 4){
		    activeShaderTask = new DiffractionShaderTask();
		}
	}
	
	private void setUpMaterials(){
		mat = new Material();
		mat.setMaterialColor(new Vector3f(0, 0f, 0f));
		mat.setShinnyCoefficient(new Vector3f(0f, 0f, 1f));
		mat.setAmbientCoefficient(new Vector3f(0.0f, 0.0f, 1.0f));
		mat.setPhongExponent(64f);
		mat.setTrackDistance(trackDistance);
		
		
		mat.setLayerCount(108);
		if(version == 10 || version == 11) mat.setLayerCount(62);
		
		Shader shader = renderContext.makeShader();
		try {
			
			if(version==1){
	
			}else if(version == 4){
				shader.load(ShaderPaths.stamVert.toString(), ShaderPaths.stamFrag.toString());
					
			}else if(version == 9){
//				shader.load(ShaderPaths.grid_1d_Vert.toString(), ShaderPaths.grid_1d_Frag.toString());|
//				shader.load(ShaderPaths.grid_1d_Vert.toString(), ShaderPaths.grid_1d_Frag.toString());
				//shader.load(ShaderPaths.grid_2d_Vert.toString(), ShaderPaths.grid_2d_Frag.toString());
//				shader.load(ShaderPaths.grid_T_1dVert.toString(), ShaderPaths.grid_T_1dFrag.toString());
				shader.load(ShaderPaths.grid_T_2dVert.toString(), ShaderPaths.grid_T_2dFrag.toString());
			}else if(version == 10){
				
//				shader.load(ShaderPaths.taylor_1d_Vert.toString(), ShaderPaths.taylor_1d_Frag.toString());
//				shader.load(ShaderPaths.taylor_2d_Vert.toString(), ShaderPaths.taylor_2d_Frag.toString());
//				shader.load(ShaderPaths.taylor_T_1d_Vert.toString(), ShaderPaths.taylor_T_1d_Frag.toString());
				shader.load(ShaderPaths.taylor_T_2d_Vert.toString(), ShaderPaths.taylor_T_2d_Frag.toString());
				
			}else if(version == 11){
				shader.load(ShaderPaths.expTaylor_2d_Vert.toString(), ShaderPaths.expTaylor_2d_Frag.toString());
			}
			

		} catch (Exception e) {}
		
		mat.setShader(shader);
		
		String samples = null;
		String extrema = null;
		
		if(version == 9 || version == 10 || version == 11){
			if(version==1){

				
			// using bmp rgb	
			}else if(version == 9){
				// basis
//				samples = "../jrtr/textures/sampleX/rgb1/";;
//				extrema = "../jrtr/textures/sampleX/rgb1/extrema.txt";;
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/rgb1/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/rgb1/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/rgb1/weights.txt"));
//				
				
				
//				samples = "../jrtr/textures/sampleX/milestone/1dw10/";
//				extrema = "../jrtr/textures/sampleX/milestone/1dw10/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/1dw10/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/1dw10/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/1dw10/weights.txt"));
				
				// basis comparision
				samples = "../jrtr/textures/sampleX/milestone/1dw20/";
				extrema = "../jrtr/textures/sampleX/milestone/1dw20/extrema.txt";
				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/1dw20/kvalues.txt"));
				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/1dw20/globals.txt"));
				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/1dw20/weights.txt"));
//				
				
				
//				samples = "../jrtr/textures/sampleX/2dStam_1/";
//				extrema = "../jrtr/textures/sampleX/2dStam_1/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/2dStam_1/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/2dStam_1/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/2dStam_1/weights.txt"));
				

				
				
//				samples = "../jrtr/textures/sampleX/milestone/1dw30/";
//				extrema = "../jrtr/textures/sampleX/milestone/1dw30/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/1dw30/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/1dw30/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/1dw30/weights.txt"));
				
				
//				samples = "../jrtr/textures/sampleX/milestone/1dspec/";
//				extrema = "../jrtr/textures/sampleX/milestone/1dspec/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/1dspec/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/1dspec/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/1dspec/weights.txt"));
				
				
//				samples = "../jrtr/textures/sampleX/milestone/tri/";
//				extrema = "../jrtr/textures/sampleX/milestone/tri/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/tri/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/tri/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/tri/weights.txt"));
				
				
//				samples = "../jrtr/textures/sampleX/milestone/sin/";
//				extrema = "../jrtr/textures/sampleX/milestone/sin/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/sin/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/sin/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/sin/weights.txt"));
				
//				samples = "../jrtr/textures/sampleX/milestone/crossw20/";
//				extrema = "../jrtr/textures/sampleX/milestone/crossw20/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/crossw20/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/crossw20/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/crossw20/weights.txt"));
				
//				samples = "../jrtr/textures/sampleX/milestone/C/";
//				extrema = "../jrtr/textures/sampleX/milestone/C/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/C/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/C/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/C/weights.txt"));
				
				
//				samples = "../jrtr/textures/sampleX/milestone/cos/";
//				extrema = "../jrtr/textures/sampleX/milestone/cos/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/cos/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/cos/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/cos/weights.txt"));
				

				
//				samples = "../jrtr/textures/sampleX/milestone/pew/";
//				extrema = "../jrtr/textures/sampleX/milestone/pew/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/pew/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/pew/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/pew/weights.txt"));

				String s_name1 = "1dStam";
				String s_name2 = "2dStam";
				String s_name3 = "blaze";
				String s_name4 = "cos";
				String s_name = s_name1;
				samples = "../jrtr/textures/sampleX/padded/"+ s_name +"/";
				extrema = "../jrtr/textures/sampleX/padded/"+ s_name +"/extrema.txt";
				mat.setKValues(loadKValues("../jrtr/textures/sampleX/padded/"+ s_name +"/kvalues.txt"));
				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/padded/"+ s_name +"/globals.txt"));
				mat.setWeights(readWeights("../jrtr/textures/sampleX/padded/"+ s_name +"/weights.txt"));

//				
				
//				samples = "../jrtr/textures/sampleX/milestone/blaze/";
//				extrema = "../jrtr/textures/sampleX/milestone/blaze/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/milestone/blaze/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/milestone/blaze/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/milestone/blaze/weights.txt"));
				
			}else if(version == 10){
//				samples = "../jrtr/textures/sampleX/taylor/w10/";
//				extrema = "../jrtr/textures/sampleX/taylor/w10/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/w10/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/w10/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/w10/weights.txt"));
//				
//				samples = "../jrtr/textures/sampleX/taylor/w20/";
//				extrema = "../jrtr/textures/sampleX/taylor/w20/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/w20/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/w20/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/w20/weights.txt"));
				
				samples = "../jrtr/textures/sampleX/taylor/pewpew/";
				extrema = "../jrtr/textures/sampleX/taylor/pewpew/extrema.txt";
				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/pewpew/kvalues.txt"));
				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/pewpew/globals.txt"));
				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/pewpew/weights.txt"));
				
//				samples = "../jrtr/textures/sampleX/taylor/newA/";
//				extrema = "../jrtr/textures/sampleX/taylor/newA/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/newA/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/newA/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/newA/weights.txt"));
//				
//				samples = "../jrtr/textures/sampleX/taylor/w30/";
//				extrema = "../jrtr/textures/sampleX/taylor/w30/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/w30/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/w30/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/w30/weights.txt"));
//				
//				samples = "../jrtr/textures/sampleX/taylor/cos/";
//				extrema = "../jrtr/textures/sampleX/taylor/cos/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/cos/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/cos/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/cos/weights.txt"));
//				
//				samples = "../jrtr/textures/sampleX/taylor/blaze/";
//				extrema = "../jrtr/textures/sampleX/taylor/blaze/extrema.txt";
//				mat.setKValues(loadKValues("../jrtr/textures/sampleX/taylor/blaze/kvalues.txt"));
//				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/taylor/blaze/globals.txt"));
//				mat.setWeights(readWeights("../jrtr/textures/sampleX/taylor/blaze/weights.txt"));
				
			}else if(version == 11){
				samples = "../jrtr/textures/sampleX/expTaylor/blaze/";
				extrema = "../jrtr/textures/sampleX/expTaylor/blaze/extrema.txt";
				mat.setGlobals(loadglobals("../jrtr/textures/sampleX/expTaylor/blaze/globals.txt"));
				mat.setWeights(readWeights("../jrtr/textures/sampleX/expTaylor/blaze/weights.txt"));
			}
			
			if(version == 10 || version == 11) loadTaylorPatches(samples);
			else loadPatches2(samples, false, true);
			
			mat.setHeightfieldFactors(loadScalingConstants(extrema));
		}

	}
	
	// TODO again check this method - for santy's sake!!!
	private void loadTaylorPatches(String basisPath){
		String path = basisPath;
		String ext = ".bmp";
		int counter = 0;
{'fraction_non_alphanumeric': 0.17767933588951346, 'fraction_numerical': 0.015485984439563711, 'mean_word_length': 3.747967479674797, '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': '2401792', 'n_tokens_mistral': 11636, 'n_tokens_neox': 10234, 'n_words': 962}