<commit_before>package br.ufscar.cgm;

import java.awt.BorderLayout;
import java.io.IOException;
import java.io.InputStream;

import javax.media.opengl.DebugGL;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.GLUquadric;
import javax.swing.JFrame;

import com.sun.opengl.util.FPSAnimator;
import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureData;
import com.sun.opengl.util.texture.TextureIO;

/**
 * A minimal JOGL demo.
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @since 26 Feb 2009
 */
public class SolarSystem extends GLCanvas implements GLEventListener {

    /** The GL unit (helper class). */
    private GLU glu;

    /** The frames per second setting. */
    private int fps = 60;

    /** The OpenGL animator. */
    private FPSAnimator animator;

    /** Textures. */
    private Texture sunTexture;
    private Texture mercuryTexture;
    private Texture venusTexture;
    private Texture earthTexture;
    private Texture marsTexture;
    private Texture moonTexture;
    private Texture starsTexture;
    
    private float galaxyAngle = 0;
    private float sunAngle = 0;
    private float mercuryAngle = 0;
    private float venusAngle = 0;
    private float earthAngle = 0;
    private float marsAngle = 0;
    private float mercuryPlanetAngle = 0;
    private float venusPlanetAngle = 0;
    private float earthPlanetAngle = 0;
    private float marsPlanetAngle = 0;
    private float moonAngle = 0;
    
    /** The angle of the satellite orbit (0..359). */
    private float satelliteAngle = 0;

    /** The texture for a solar panel. */
    private Texture solarPanelTexture;
    
        /**
     * Starts the JOGL mini demo.
     * 
     * @param args Command line args.
     */
    public final static void main(String[] args) {
        GLCapabilities capabilities = createGLCapabilities();
        SolarSystem canvas = new SolarSystem(capabilities, 800, 500);
        JFrame frame = new JFrame("Trabalho 4 CGM");
        frame.getContentPane().add(canvas, BorderLayout.CENTER);
        frame.setSize(800, 500);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
        canvas.requestFocus();
    }

    /**
     * A new mini starter.
     * 
     * @param capabilities The GL capabilities.
     * @param width The window width.
     * @param height The window height.
     */
    public SolarSystem(GLCapabilities capabilities, int width, int height) {
        addGLEventListener(this);
    }

    /**
     * @return Some standard GL capabilities (with alpha).
     */
    private static GLCapabilities createGLCapabilities() {
        GLCapabilities capabilities = new GLCapabilities();
        capabilities.setRedBits(8);
        capabilities.setBlueBits(8);
        capabilities.setGreenBits(8);
        capabilities.setAlphaBits(8);
        return capabilities;
    }

    /**
     * Sets up the screen.
     * 
     * @see javax.media.opengl.GLEventListener#init(javax.media.opengl.GLAutoDrawable)
     */
    public void init(GLAutoDrawable drawable) {
        drawable.setGL(new DebugGL(drawable.getGL()));
        final GL gl = drawable.getGL();

        // Enable z- (depth) buffer for hidden surface removal. 
        gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glDepthFunc(GL.GL_LEQUAL);

        // Enable smooth shading.
        gl.glShadeModel(GL.GL_SMOOTH);

        // Define "clear" color.
        gl.glClearColor(0f, 0f, 0f, 0f);

        // We want a nice perspective.
        gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);

        // Create GLU.
        glu = new GLU();

        // Load textures.
        try {
            InputStream stream = getClass().getResourceAsStream("textures/sun.png");
            TextureData data = TextureIO.newTextureData(stream, false, "png");
            sunTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/mercury.png");
            data = TextureIO.newTextureData(stream, false, "png");
            mercuryTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/neptune.png");
            data = TextureIO.newTextureData(stream, false, "png");
            venusTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/earth2.png");
            data = TextureIO.newTextureData(stream, false, "png");
            earthTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/mars.png");
            data = TextureIO.newTextureData(stream, false, "png");
            marsTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/stars2.png");
            data = TextureIO.newTextureData(stream, false, "png");
            starsTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/moon.png");
            data = TextureIO.newTextureData(stream, false, "png");
            moonTexture = TextureIO.newTexture(data);
        }
        catch (IOException exc) {
            System.out.print("Arquivos de Textura não foram encontrados.");
            System.exit(1);
        }

        // Load the solar panel texture.
        try {
            InputStream stream = getClass().getResourceAsStream("textures/stars2.png");
            TextureData data = TextureIO.newTextureData(stream, false, "png");
            solarPanelTexture = TextureIO.newTexture(data);
        }
        catch (IOException exc) {
            exc.printStackTrace();
            System.exit(2);
        }

        // Start animator.
        animator = new FPSAnimator(this, fps);
        animator.start();
    }

    /**
     * The only method that you should implement by yourself.
     * 
     * @see javax.media.opengl.GLEventListener#display(javax.media.opengl.GLAutoDrawable)
     */
    public void display(GLAutoDrawable drawable) {
        if (!animator.isAnimating()) {
            return;
        }
        final GL gl = drawable.getGL();

        // Clear screen.
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

        // Set camera.
        // Change to projection matrix.
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();

        // Perspective.
        float widthHeightRatio = (float) getWidth() / (float) getHeight();
        glu.gluPerspective(45, widthHeightRatio, 1, 1000);
        glu.gluLookAt(200, 200, 200, 
                0, 0, 0, 
                0, 1, 0);

        // Change back to model view matrix.
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();

        // Prepare light parameters.
        float SHINE_ALL_DIRECTIONS = 1;
        float[] lightPos = {-30, 0, 0, SHINE_ALL_DIRECTIONS};
        float[] lightColorAmbient = {0.2f, 0.2f, 0.2f, 1f};
        float[] lightColorSpecular = {0.8f, 0.8f, 0.8f, 1f};

        // Set light parameters.
        gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, lightPos, 0);
        gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, lightColorAmbient, 0);
        gl.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, lightColorSpecular, 0);

        // Enable lighting in GL.
        gl.glEnable(GL.GL_LIGHT1);
        gl.glEnable(GL.GL_LIGHTING);

        // Set material properties.
        float[] rgba = {1f, 1f, 1f};
        gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, rgba, 0);
        gl.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, rgba, 0);
        gl.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, 0.5f);
        
        
        galaxyAngle++;
        gl.glRotated(galaxyAngle,0,1,0);
        gl.glPushMatrix();
        float radius;
        int slices;
        int stacks;
        
        //Sun
        sunTexture.bind();
        GLUquadric quadric = glu.gluNewQuadric();
        glu.gluQuadricTexture(quadric, true);
        glu.gluQuadricDrawStyle(quadric, GLU.GLU_FILL);
        glu.gluQuadricNormals(quadric, GLU.GLU_FLAT);
        glu.gluQuadricOrientation(quadric, GLU.GLU_OUTSIDE);
        radius = 20f;
        slices = 10;
        stacks = 10;
        sunAngle += 0.1;
        gl.glRotated(-galaxyAngle,0,1,0);
        gl.glRotated(sunAngle,0,1,0);
        glu.gluSphere(quadric, radius, slices, stacks);
        
        //Mercury
        mercuryTexture.bind();
        radius = 3.4f;
        slices = 16;
        stacks = 16;
        gl.glPopMatrix();
        gl.glPushMatrix();
        mercuryPlanetAngle += 0.74;
        mercuryAngle += Math.E/10;
        gl.glRotated(mercuryPlanetAngle,0,1,0);
        gl.glTranslated(20, 0, 20);
        gl.glRotated(mercuryAngle,0,1,0);
        glu.gluSphere(quadric, radius, slices, stacks);
        
        //Venus
        venusTexture.bind();
        radius = 8.6f;
        slices = 16;
        stacks = 16;
        gl.glPopMatrix();
        gl.glPushMatrix();
        venusPlanetAngle += 0.54;
        venusAngle += -1.0/10;
        gl.glRotated(venusPlanetAngle,0,1,0);
        gl.glTranslated(35, 0, 40);
        gl.glRotated(venusAngle,0,1,0);<commit_msg>Corrige textura do sol muito escura.<commit_after>package br.ufscar.cgm;

import java.awt.BorderLayout;
import java.io.IOException;
import java.io.InputStream;

import javax.media.opengl.DebugGL;
import javax.media.opengl.GL;
import javax.media.opengl.GLAutoDrawable;
import javax.media.opengl.GLCanvas;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLEventListener;
import javax.media.opengl.glu.GLU;
import javax.media.opengl.glu.GLUquadric;
import javax.swing.JFrame;

import com.sun.opengl.util.FPSAnimator;
import com.sun.opengl.util.texture.Texture;
import com.sun.opengl.util.texture.TextureData;
import com.sun.opengl.util.texture.TextureIO;

/**
 * A minimal JOGL demo.
 * 
 * @author <a href="mailto:<EMAIL>"><NAME></a>
 * @since 26 Feb 2009
 */
public class SolarSystem extends GLCanvas implements GLEventListener {

    /** The GL unit (helper class). */
    private GLU glu;

    /** The frames per second setting. */
    private int fps = 60;

    /** The OpenGL animator. */
    private FPSAnimator animator;

    /** Textures. */
    private Texture sunTexture;
    private Texture mercuryTexture;
    private Texture venusTexture;
    private Texture earthTexture;
    private Texture marsTexture;
    private Texture moonTexture;
    private Texture starsTexture;
    
    private float galaxyAngle = 0;
    private float sunAngle = 0;
    private float mercuryAngle = 0;
    private float venusAngle = 0;
    private float earthAngle = 0;
    private float marsAngle = 0;
    private float mercuryPlanetAngle = 0;
    private float venusPlanetAngle = 0;
    private float earthPlanetAngle = 0;
    private float marsPlanetAngle = 0;
    private float moonAngle = 0;
    
    /** The angle of the satellite orbit (0..359). */
    private float satelliteAngle = 0;

    /** The texture for a solar panel. */
    private Texture solarPanelTexture;
    
        /**
     * Starts the JOGL mini demo.
     * 
     * @param args Command line args.
     */
    public final static void main(String[] args) {
        GLCapabilities capabilities = createGLCapabilities();
        SolarSystem canvas = new SolarSystem(capabilities, 800, 500);
        JFrame frame = new JFrame("Trabalho 4 CGM");
        frame.getContentPane().add(canvas, BorderLayout.CENTER);
        frame.setSize(800, 500);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setVisible(true);
        canvas.requestFocus();
    }

    /**
     * A new mini starter.
     * 
     * @param capabilities The GL capabilities.
     * @param width The window width.
     * @param height The window height.
     */
    public SolarSystem(GLCapabilities capabilities, int width, int height) {
        addGLEventListener(this);
    }

    /**
     * @return Some standard GL capabilities (with alpha).
     */
    private static GLCapabilities createGLCapabilities() {
        GLCapabilities capabilities = new GLCapabilities();
        capabilities.setRedBits(8);
        capabilities.setBlueBits(8);
        capabilities.setGreenBits(8);
        capabilities.setAlphaBits(8);
        return capabilities;
    }

    /**
     * Sets up the screen.
     * 
     * @see javax.media.opengl.GLEventListener#init(javax.media.opengl.GLAutoDrawable)
     */
    public void init(GLAutoDrawable drawable) {
        drawable.setGL(new DebugGL(drawable.getGL()));
        final GL gl = drawable.getGL();

        // Enable z- (depth) buffer for hidden surface removal. 
        gl.glEnable(GL.GL_DEPTH_TEST);
        gl.glDepthFunc(GL.GL_LEQUAL);

        // Enable smooth shading.
        gl.glShadeModel(GL.GL_SMOOTH);

        // Define "clear" color.
        gl.glClearColor(0f, 0f, 0f, 0f);

        // We want a nice perspective.
        gl.glHint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST);

        // Create GLU.
        glu = new GLU();

        // Load textures.
        try {
            InputStream stream = getClass().getResourceAsStream("textures/sun.png");
            TextureData data = TextureIO.newTextureData(stream, false, "png");
            sunTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/mercury.png");
            data = TextureIO.newTextureData(stream, false, "png");
            mercuryTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/neptune.png");
            data = TextureIO.newTextureData(stream, false, "png");
            venusTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/earth2.png");
            data = TextureIO.newTextureData(stream, false, "png");
            earthTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/mars.png");
            data = TextureIO.newTextureData(stream, false, "png");
            marsTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/stars2.png");
            data = TextureIO.newTextureData(stream, false, "png");
            starsTexture = TextureIO.newTexture(data);
            stream = getClass().getResourceAsStream("textures/moon.png");
            data = TextureIO.newTextureData(stream, false, "png");
            moonTexture = TextureIO.newTexture(data);
        }
        catch (IOException exc) {
            System.out.print("Arquivos de Textura não foram encontrados.");
            System.exit(1);
        }

        // Load the solar panel texture.
        try {
            InputStream stream = getClass().getResourceAsStream("textures/stars2.png");
            TextureData data = TextureIO.newTextureData(stream, false, "png");
            solarPanelTexture = TextureIO.newTexture(data);
        }
        catch (IOException exc) {
            exc.printStackTrace();
            System.exit(2);
        }

        // Start animator.
        animator = new FPSAnimator(this, fps);
        animator.start();
    }

    /**
     * The only method that you should implement by yourself.
     * 
     * @see javax.media.opengl.GLEventListener#display(javax.media.opengl.GLAutoDrawable)
     */
    public void display(GLAutoDrawable drawable) {
        if (!animator.isAnimating()) {
            return;
        }
        final GL gl = drawable.getGL();

        // Clear screen.
        gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);

        // Set camera.
        // Change to projection matrix.
        gl.glMatrixMode(GL.GL_PROJECTION);
        gl.glLoadIdentity();

        // Perspective.
        float widthHeightRatio = (float) getWidth() / (float) getHeight();
        glu.gluPerspective(45, widthHeightRatio, 1, 1000);
        glu.gluLookAt(200, 200, 200, 
                0, 0, 0, 
                0, 1, 0);

        // Change back to model view matrix.
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();

        // Prepare light parameters.
        float SHINE_ALL_DIRECTIONS = 1;
        float[] lightPos = {-30, 0, 0, SHINE_ALL_DIRECTIONS};
        float[] lightColorAmbient = {0.2f, 0.2f, 0.2f, 1f};
        float[] lightColorSpecular = {0.8f, 0.8f, 0.8f, 1f};

        // Set light parameters.
        gl.glLightfv(GL.GL_LIGHT1, GL.GL_POSITION, lightPos, 0);
        gl.glLightfv(GL.GL_LIGHT1, GL.GL_AMBIENT, lightColorAmbient, 0);
        gl.glLightfv(GL.GL_LIGHT1, GL.GL_SPECULAR, lightColorSpecular, 0);

        // Enable lighting in GL.
        gl.glEnable(GL.GL_LIGHT1);
        gl.glEnable(GL.GL_LIGHTING);

        // Set material properties.
        float[] rgba = {1f, 1f, 1f};
        gl.glMaterialfv(GL.GL_FRONT, GL.GL_AMBIENT, rgba, 0);
        gl.glMaterialfv(GL.GL_FRONT, GL.GL_SPECULAR, rgba, 0);
        gl.glMaterialf(GL.GL_FRONT, GL.GL_SHININESS, 0.5f);
        
        
        galaxyAngle++;
        gl.glRotated(galaxyAngle,0,1,0);
        gl.glPushMatrix();
        float radius;
        int slices;
        int stacks;
        
        //Sun
        sunTexture.bind();
        GLUquadric quadric = glu.gluNewQuadric();
        glu.gluQuadricTexture(quadric, true);
        glu.gluQuadricDrawStyle(quadric, GLU.GLU_FILL);
        glu.gluQuadricNormals(quadric, GLU.GLU_FLAT);
        glu.gluQuadricOrientation(quadric, GLU.GLU_INSIDE);
        radius = 20f;
        slices = 10;
        stacks = 10;
        sunAngle += 0.1;
        gl.glRotated(-galaxyAngle,0,1,0);
        gl.glRotated(sunAngle,0,1,0);
        glu.gluSphere(quadric, radius, slices, stacks);
        
        //Mercury
        mercuryTexture.bind();
        glu.gluQuadricOrientation(quadric, GLU.GLU_OUTSIDE);
        radius = 3.4f;
        slices = 16;
        stacks = 16;
        gl.glPopMatrix();
        gl.glPushMatrix();
        mercuryPlanetAngle += 0.74;
        mercuryAngle += Math.E/10;
        gl.glRotated(mercuryPlanetAngle,0,1,0);
        gl.glTranslated(20, 0, 20);
        gl.glRotated(mercuryAngle,0,1,0);
        glu.gluSphere(quadric, radius, slices, stacks);
        
        //Venus
        venusTexture.bind();
        radius = 8.6f;
        slices = 16;
        stacks = 16;
        gl.glPopMatrix();
        gl.glPushMatrix();
        venusPlanetAngle += 0.54;
        venusAngle += -1.0/10;
        gl.glRotated(venusPlanetAngle,0,1,0);
        gl.glTranslated(35, 0, 40);
        gl.glRotated(venusAngle,0,1,0);
{'fraction_non_alphanumeric': 0.11407518958747916, 'fraction_numerical': 0.018071317162372934, 'mean_word_length': 2.3352466367713003, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5517816', 'n_tokens_mistral': 6137, 'n_tokens_neox': 5820, 'n_words': 1204}