<commit_before>/**
 * 
 */
package br.odb.derelict;

import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.List;

import javax.swing.JFrame;
import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import br.odb.libscene.SceneNode;
import br.odb.libscene.World;
import br.odb.libscene.builders.WorldLoader;

import com.jogamp.opengl.util.FPSAnimator;

/**
 * @author monty
 *
 */
public class Editor3DViewerDriverApp {
	
	private static final int CANVAS_WIDTH = 640;
	private static final int CANVAS_HEIGHT = 480;
	private static final int FPS = 60;
	
	public static void main(String[] args) {
		new Thread(new Runnable() {
			private World world;
			//private SVGGraphic graphic;
			//private GeneralTriangle[] decal;

			@Override
			public void run() {

				Editor3DViewer canvas = new Editor3DViewer();

				try {
					FileInputStream fis = new FileInputStream(
							System.getProperty( "user.home" ) + "/ang2l1.opt.xml");
					 
					world = WorldLoader.build(fis);
					canvas.tesselator.generateSubSectorQuadsForWorld(world);
					
//					FileInputStream filePath = new FileInputStream(
//							System.getProperty( "user.home" ) + "/title.bin");
					
					//decal = Decal.loadGraphic( filePath, 800, 480 );
				} catch (FileNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (SAXException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (ParserConfigurationException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}

				
				final List<SceneNode> srs = world.getAllRegionsAsList();
				canvas.cameraPosition.set( srs.get( srs.size() - 1 ).getAbsolutePosition() );
			
				canvas.setScene( world );
				
//				for ( GeneralTriangle gt : decal ) {
//					gt.x0 += canvas.cameraPosition.x;
//					gt.x1 += canvas.cameraPosition.x;
//					gt.x2 += canvas.cameraPosition.x;
//
//					gt.y0 += canvas.cameraPosition.y;
//					gt.y1 += canvas.cameraPosition.y;
//					gt.y2 += canvas.cameraPosition.y;
//					
//					gt.z0 += canvas.cameraPosition.z;
//					gt.z1 += canvas.cameraPosition.z;
//					gt.z2 += canvas.cameraPosition.z;
//					
//					canvas.polysToRender.add( gt );
//				}				
				
				System.out.println( "loaded " + canvas.polysToRender.size() + " polys" );
				canvas.setPreferredSize(new Dimension(CANVAS_WIDTH,
						CANVAS_HEIGHT));

				final FPSAnimator animator = new FPSAnimator(canvas, FPS, true);

				// Create the top-level container
				final JFrame frame = new JFrame(); // Swing's JFrame or AWT's
													// Frame
				frame.getContentPane().add(canvas);
<commit_msg>Add a 3D model to the map<commit_after>/**
 * 
 */
package br.odb.derelict;

import java.awt.Dimension;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JFrame;
import javax.xml.parsers.ParserConfigurationException;

import org.xml.sax.SAXException;

import br.odb.liboldfart.WavefrontMaterialLoader;
import br.odb.liboldfart.WavefrontOBJLoader;
import br.odb.libscene.SceneNode;
import br.odb.libscene.World;
import br.odb.libscene.builders.WorldLoader;
import br.odb.libstrip.GeneralTriangle;
import br.odb.libstrip.GeneralTriangleMesh;
import br.odb.libstrip.Material;
import br.odb.libstrip.builders.GeneralTriangleFactory;

import com.jogamp.opengl.util.FPSAnimator;

/**
 * @author monty
 *
 */
public class Editor3DViewerDriverApp {
	
	private static final int CANVAS_WIDTH = 640;
	private static final int CANVAS_HEIGHT = 480;
	private static final int FPS = 60;
	
	public static void main(String[] args) {
		new Thread(new Runnable() {
			private World world;
			//private SVGGraphic graphic;
			//private GeneralTriangle[] decal;
			GeneralTriangleMesh enemy;

			@Override
			public void run() {

				Editor3DViewer canvas = new Editor3DViewer();

				try {
					FileInputStream fis = new FileInputStream(
							System.getProperty( "user.home" ) + "/floor1.opt.xml");
					 
					world = WorldLoader.build(fis);
					canvas.tesselator.generateSubSectorQuadsForWorld(world);
					
//					FileInputStream filePath = new FileInputStream(
//							System.getProperty( "user.home" ) + "/title.bin");
					
					//decal = Decal.loadGraphic( filePath, 800, 480 );
										
		            WavefrontMaterialLoader matLoader = new WavefrontMaterialLoader();
		            List<Material> mats = matLoader.parseMaterials( new FileInputStream(
							System.getProperty( "user.home" ) + "/gargoyle.mtl") );


		            WavefrontOBJLoader loader = new WavefrontOBJLoader( new GeneralTriangleFactory() );
		            ArrayList<GeneralTriangleMesh> mesh = (ArrayList<GeneralTriangleMesh>) loader.loadMeshes( new FileInputStream(
							System.getProperty( "user.home" ) + "/gargoyle.obj"), mats );

		            enemy = mesh.get( 0 );
//		            enemy.scale( 10.0f );          
		            
					
					
				} catch (FileNotFoundException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (IOException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (SAXException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (ParserConfigurationException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}

				
				final List<SceneNode> srs = world.getAllRegionsAsList();
				canvas.cameraPosition.set( srs.get( srs.size() - 1 ).getAbsolutePosition() );
			
				canvas.setScene( world );
				
				enemy.translateTo( canvas.cameraPosition );
				
	            for ( GeneralTriangle gt : enemy.faces ) {
	            	canvas.polysToRender.add( gt );	
	            }
				
//				for ( GeneralTriangle gt : decal ) {
//					gt.x0 += canvas.cameraPosition.x;
//					gt.x1 += canvas.cameraPosition.x;
//					gt.x2 += canvas.cameraPosition.x;
//
//					gt.y0 += canvas.cameraPosition.y;
//					gt.y1 += canvas.cameraPosition.y;
//					gt.y2 += canvas.cameraPosition.y;
//					
//					gt.z0 += canvas.cameraPosition.z;
//					gt.z1 += canvas.cameraPosition.z;
//					gt.z2 += canvas.cameraPosition.z;
//					
//					canvas.polysToRender.add( gt );
//				}				
				
				System.out.println( "loaded " + canvas.polysToRender.size() + " polys" );
				canvas.setPreferredSize(new Dimension(CANVAS_WIDTH,
						CANVAS_HEIGHT));

				final FPSAnimator animator = new FPSAnimator(canvas, FPS, true);

				// Create the top-level container
				final JFrame frame = new JFrame(); // Swing's JFrame or AWT's
													// Frame
				frame.getContentPane().add(canvas);

{'fraction_non_alphanumeric': 0.1226590421729807, 'fraction_numerical': 0.011150822015725518, 'mean_word_length': 2.8334246575342465, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 6}, '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': '2017175', 'n_tokens_mistral': 2771, 'n_tokens_neox': 2200, 'n_words': 459}