Java-Gaming.org Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (755)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
  JavaGaming.org - Pastebin



Author: bjgil2 (posted 2013-01-07 05:41:41, viewed 1166 times)

1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200   201   202   203   204   205   206   207   208   209   210   211   212   213   214   215   216   217   218   219   220   221   222   223   224   225   226   227   228   229   230   231   232   233   234   235   236   237   238   239   240   241   242   243   244   245   246   247   248   249   250   251   252   253   254   255   256   257   258   259   260   261   262   263   264   265   266   267   268   269   270   271   272   273   274   275   276   277   278   279   280   281   282   283   284   285   286   287   288   289   290   291   292   293   294   295   296   297   298   299   300   301   302   303   304   305   306   307   308   309   310   311   312   313   314   315   316   317   318   319   320   321   322   323   324   325   326   327   328   329   330   331   332   333   334   335   336   337   338   339   340   341   342   343   344   345   346   347   348   349   350   351   352   353   354   355   356   357   358   359   360   361   362   363   364   365   366   367   368   369   370   371   372   373   374   375   376   377   378   379   380   381   382   383   384   385  
package com.test;

import static org.lwjgl.opengl.ARBShaderObjects.GL_OBJECT_COMPILE_STATUS_ARB;
import static org.lwjgl.opengl.ARBShaderObjects.GL_OBJECT_INFO_LOG_LENGTH_ARB;
import static org.lwjgl.opengl.ARBShaderObjects.glGetInfoLogARB;
import static org.lwjgl.opengl.ARBShaderObjects.glGetObjectParameteriARB;
import static org.lwjgl.opengl.GL11.*;
import static org.lwjgl.opengl.GL20.*;

import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import org.lwjgl.util.glu.GLU;
import org.lwjgl.util.glu.Sphere;

public class AtmosphereOneill {

   public static final String VERTEX_SHADER = "uniform vec3 v3CameraPos;      /* The camera's current position*/\n"
         + "uniform vec3 v3LightPos;      /* The direction vector to the light source*/\n"
         + "uniform vec3 v3InvWavelength;   /* 1 / pow(wavelength, 4) for the red, green, and blue channels*/\n"
         + "uniform float fCameraHeight;   /* The camera's current height*/\n"
         + "uniform float fCameraHeight2;   /* fCameraHeight^2*/\n"
         + "uniform float fOuterRadius;   /* The outer (atmosphere) radius*/\n"
         + "uniform float fOuterRadius2;   /* fOuterRadius^2*/\n"
         + "uniform float fInnerRadius;   /* The inner (planetary) radius*/\n"
         + "uniform float fInnerRadius2;   /* fInnerRadius^2*/\n"
         + "uniform float fKrESun;         /* Kr * ESun*/\n"
         + "uniform float fKmESun;         /* Km * ESun*/\n"
         + "uniform float fKr4PI;         /* Kr * 4 * PI*/\n"
         + "uniform float fKm4PI;         /* Km * 4 * PI*/\n"
         + "uniform float fScale;         /* 1 / (fOuterRadius - fInnerRadius)*/\n"
         + "uniform float fScaleDepth;      /* The scale depth (i.e. the altitude at which the atmosphere's average density is found)*/\n"
         + "uniform float fScaleOverScaleDepth;   /* fScale / fScaleDepth*/\n"
         + "\n"
         + "uniform int nSamples;\n"
         + "uniform float fSamples;\n"
         + "\n"
         + "varying vec3 v3Direction;\n"
         + "\n"
         + "float scale(float fCos)\n"
         + "{\n"
         + "   float x = 1.0 - fCos;\n"
         + "   return fScaleDepth * exp(-0.00287 + x*(0.459 + x*(3.83 + x*(-6.80 + x*5.25))));\n"
         + "}\n"
         + "\n"
         + "void main(void)\n"
         + "{\n"
         + "\n"
         + "   /* Get the ray from the camera to the vertex, and its length (which is the far point of the ray passing through the atmosphere)*/\n"
         + "   vec3 v3Pos = gl_Vertex.xyz;\n"
         + "   vec3 v3Ray = v3Pos - v3CameraPos;\n"
         + "   float fFar = length(v3Ray);\n"
         + "   v3Ray /= fFar;\n"
         + "\n"
         + "   /* Calculate the ray's starting position, then calculate its scattering offset*/\n"
         + "   vec3 v3Start = v3CameraPos;\n"
         + "   float fHeight = length(v3Start);\n"
         + "   float fDepth = exp(fScaleOverScaleDepth * (fInnerRadius - fCameraHeight));\n"
         + "   float fStartAngle = dot(v3Ray, v3Start) / fHeight;\n"
         + "   float fStartOffset = fDepth*scale(fStartAngle);\n"
         + "\n"
         + "   /* Initialize the scattering loop variables*/\n"
         + "   //gl_FrontColor = vec4(0.0, 0.0, 0.0, 0.0);\n"
         + "   float fSampleLength = fFar / fSamples;\n"
         + "   float fScaledLength = fSampleLength * fScale;\n"
         + "   vec3 v3SampleRay = v3Ray * fSampleLength;\n"
         + "   vec3 v3SamplePoint = v3Start + v3SampleRay * 0.5;\n"
         + "\n"
         + "   // Now loop through the sample rays\n"
         + "   vec3 v3FrontColor = vec3(0.0, 0.0, 0.0);\n"
         + "   for(int i=0; i<nSamples; i++)\n"
         + "   {\n"
         + "      float fHeight = length(v3SamplePoint);\n"
         + "      float fDepth = exp(fScaleOverScaleDepth * (fInnerRadius - fHeight));\n"
         + "      float fLightAngle = dot(v3LightPos, v3SamplePoint) / fHeight;\n"
         + "      float fCameraAngle = dot(v3Ray, v3SamplePoint) / fHeight;\n"
         + "      float fScatter = (fStartOffset + fDepth*(scale(fLightAngle) - scale(fCameraAngle)));\n"
         + "      vec3 v3Attenuate = exp(-fScatter * (v3InvWavelength * fKr4PI + fKm4PI));\n"
         + "      v3FrontColor += v3Attenuate * (fDepth * fScaledLength);\n"
         + "      v3SamplePoint += v3SampleRay;\n"
         + "   }\n"
         + "\n"
         + "   // Finally, scale the Mie and Rayleigh colors and set up the varying variables for the pixel shader\n"
         + "   gl_FrontSecondaryColor.rgb = v3FrontColor * fKmESun;\n"
         + "   gl_FrontColor.rgb = v3FrontColor * (v3InvWavelength * fKrESun);\n"
         + "\n"
         + "   gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
         + "   v3Direction = v3CameraPos - v3Pos;\n" + "}";

   public static final String FRAGMENT_SHADER = "uniform vec3 v3LightPos;\n"
         + "uniform float g;\n"
         + "uniform float g2;\n"
         + "\n"
         + "varying vec3 v3Direction;\n"
         + "\n"
         + "void main (void)\n"
         + "{\n"
         + "   float fCos = dot(v3LightPos, v3Direction) / length(v3Direction);\n"
         + "   float fRayleighPhase = 0.75 * (1.0 + fCos*fCos);\n"
         + "   float fMiePhase = 1.5 * ((1.0 - g2) / (2.0 + g2)) * (1.0 + fCos*fCos) / pow(1.0 + g2 - 2.0*g*fCos, 1.5);\n"
         + "   gl_FragColor = fRayleighPhase * gl_Color + fMiePhase * gl_SecondaryColor;\n"
         + "   gl_FragColor.a = gl_FragColor.b;\n" + "}";

   private static final float EARTH_RADIUS = /* 6371.f */100.f;
   private static final float EARTH_ATMOSPHERE_RADIUS = EARTH_RADIUS * 1.025f;
   private static final float VIEW_DIST = EARTH_ATMOSPHERE_RADIUS * 5.f;
   Vec3 camera = new Vec3(0.f, EARTH_RADIUS, 0.f);

   Vec3 m_vLight = new Vec3(0.f, 0.0f, -1000.f);

   private static final float FOV = 70.f;

   private static final double CAMERA_Y_OFFSET = 20.0;

   private static final double CAMERA_X_ROT = 45.0;

   private Sphere sky = new Sphere();
   private int drawProg;

   float sun_x = 0.f;
   float sun_y = 0.f;
   float sun_z = 1.f;

   double sunAngle = 85.0;
   boolean updateSunAngle = true;

   public static void main(String[] argv) {
      AtmosphereOneill atmosphereOneill = new AtmosphereOneill();
      atmosphereOneill.start();
   }

   public void start() {

      sky.setOrientation(GLU.GLU_INSIDE);

      initGL(800, 600);
      init();

      while (true) {
         render();

         Display.update();
         Display.sync(100);

         if (Display.isCloseRequested()) {
            Display.destroy();
            System.exit(0);
         }
      }
   }

   public void render() {
      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

//       glPolygonMode(GL_FRONT, GL_LINE);
//       glPolygonMode(GL_BACK, GL_LINE);

      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();

      glUseProgram(drawProg);

      updateShaderParams(drawProg);

      glFrontFace(GL_CW);
      glEnable(GL_BLEND);
      glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

      glPushMatrix();
      glRotated(CAMERA_X_ROT, -1.0, 0.0, 0.0);
      glTranslated(camera.x, -camera.y - CAMERA_Y_OFFSET, camera.z);
      
      sky.draw(EARTH_ATMOSPHERE_RADIUS * 1.5f, 128, 128);
      glPopMatrix();

      glDisable(GL_BLEND);
      glFrontFace(GL_CCW);

      glUseProgram(0);

      glPushMatrix();
      glRotated(CAMERA_X_ROT, -1.0, 0.0, 0.0);
      glTranslated(camera.x, -camera.y - CAMERA_Y_OFFSET, camera.z);
      
      glColor3f(0.2f, 0.5f, 0.2f);
      sky.draw(EARTH_RADIUS, 128, 128);
      glPopMatrix();
   }

   private void updateShaderParams(int drawProg) {
      if (updateSunAngle) {
         sunAngle += 0.1;
         if (sunAngle > 190.0 && sunAngle < 350.0) {
            sunAngle = 350.0;
         } else if (sunAngle > 360.0) {
            sunAngle = 0.0;
         }
      }

      m_vLight.z = Math.cos(Math.toRadians(sunAngle));
      m_vLight.y = Math.sin(Math.toRadians(sunAngle));

      Vec3 m_vLightDirection = new Vec3(m_vLight);
      m_vLightDirection.normalise();

      int v3CameraPos = glGetUniformLocation(drawProg, "v3CameraPos");
      glUniform3f(v3CameraPos, (float) camera.x, (float) camera.y,
            (float) camera.z);

      int v3LightPos = glGetUniformLocation(drawProg, "v3LightPos");
      glUniform3f(v3LightPos, (float) m_vLightDirection.x,
            (float) m_vLightDirection.y, (float) m_vLightDirection.z);
   }
   
   private void setupProgram(int drawProg) {

      float m_Kr = 0.0025f; // Rayleigh scattering constant
      float m_Kr4PI = m_Kr * 4.0f * (float) Math.PI;
      float m_Km = 0.00015f; // Mie scattering constant
      float m_Km4PI = m_Km * 4.0f * (float) Math.PI;
      float m_ESun = 25.0f; // Sun brightness constant
      float m_g = -0.95f; // The Mie phase asymmetry factor

      float m_fInnerRadius = EARTH_RADIUS;
      float m_fOuterRadius = EARTH_ATMOSPHERE_RADIUS;

      float[] m_fWavelength = new float[3];
      float[] m_fWavelength4 = new float[3];
      m_fWavelength[0] = 0.650f; // 650 nm for red
      m_fWavelength[1] = 0.570f; // 570 nm for green
      m_fWavelength[2] = 0.475f; // 475 nm for blue
      m_fWavelength4[0] = (float) Math.pow(m_fWavelength[0], 4.0);
      m_fWavelength4[1] = (float) Math.pow(m_fWavelength[1], 4.0);
      m_fWavelength4[2] = (float) Math.pow(m_fWavelength[2], 4.0);

      float m_fRayleighScaleDepth = 1.5f;

      float m_fScale = 1.0f / (m_fOuterRadius - m_fInnerRadius);
      float m_fScaleOverScaleDepth = m_fScale / m_fRayleighScaleDepth;

      int m_nSamples = 2;

      int v3InvWavelength = glGetUniformLocation(drawProg, "v3InvWavelength");
      glUniform3f(v3InvWavelength, 1.0f / m_fWavelength4[0],
            1.0f / m_fWavelength4[1], 1.0f / m_fWavelength4[2]);

      float camLength = (float) camera.length();
      int fCameraHeight = glGetUniformLocation(drawProg, "fCameraHeight");
      glUniform1f(fCameraHeight, camLength);

      int fCameraHeight2 = glGetUniformLocation(drawProg, "fCameraHeight2");
      glUniform1f(fCameraHeight2, camLength * camLength);

      int fInnerRadius = glGetUniformLocation(drawProg, "fInnerRadius");
      glUniform1f(fInnerRadius, m_fInnerRadius);

      int fInnerRadius2 = glGetUniformLocation(drawProg, "fInnerRadius2");
      glUniform1f(fInnerRadius2, m_fInnerRadius * m_fInnerRadius);

      int fOuterRadius = glGetUniformLocation(drawProg, "fOuterRadius");
      glUniform1f(fOuterRadius, m_fOuterRadius);

      int fOuterRadius2 = glGetUniformLocation(drawProg, "fOuterRadius2");
      glUniform1f(fOuterRadius2, m_fOuterRadius * m_fOuterRadius);

      int fKrESun = glGetUniformLocation(drawProg, "fKrESun");
      glUniform1f(fKrESun, m_Kr * m_ESun);

      int fKmESun = glGetUniformLocation(drawProg, "fKmESun");
      glUniform1f(fKmESun, m_Km * m_ESun);

      int fKr4PI = glGetUniformLocation(drawProg, "fKr4PI");
      glUniform1f(fKr4PI, m_Kr4PI);

      int fKm4PI = glGetUniformLocation(drawProg, "fKm4PI");
      glUniform1f(fKm4PI, m_Km4PI);

      int fScale = glGetUniformLocation(drawProg, "fScale");
      glUniform1f(fScale, m_fScale);

      int fScaleDepth = glGetUniformLocation(drawProg, "fScaleDepth");
      glUniform1f(fScaleDepth, m_fRayleighScaleDepth);

      int fScaleOverScaleDepth = glGetUniformLocation(drawProg,
            "fScaleOverScaleDepth");
      glUniform1f(fScaleOverScaleDepth, m_fScaleOverScaleDepth);

      int g = glGetUniformLocation(drawProg, "g");
      glUniform1f(g, m_g);

      int g2 = glGetUniformLocation(drawProg, "g2");
      glUniform1f(g2, m_g * m_g);

      int nSamples = glGetUniformLocation(drawProg, "nSamples");
      glUniform1i(nSamples, m_nSamples);

      int fSamples = glGetUniformLocation(drawProg, "fSamples");
      glUniform1f(fSamples, (float) nSamples);
   }

   private void initGL(int width, int height) {
      try {
         Display.setDisplayMode(new DisplayMode(width, height));
         Display.create();
         Display.setVSyncEnabled(true);
      } catch (LWJGLException e) {
         e.printStackTrace();
         System.exit(0);
      }

      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);

      glViewport(0, 0, width, height);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      GLU.gluPerspective(FOV, ((float) width / (float) height), 0.1f,
            VIEW_DIST + 1.f);
      
      glMatrixMode(GL_MODELVIEW);
      glLoadIdentity();
      glShadeModel(GL_SMOOTH);
      glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
      glClearDepth(1.0f);
      glEnable(GL_DEPTH_TEST);
      glDepthFunc(GL_LEQUAL);
      glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
   }

   public void init() {
      drawProg = loadProgram();
      System.out.println("drawProg = " + drawProg);
      
      glUseProgram(drawProg);
      setupProgram(drawProg);
      glUseProgram(0);

   }

   private int loadProgram() {
      int programId = glCreateProgram();
      int vertexShaderId = glCreateShader(GL_VERTEX_SHADER);
      int fragmentShaderId = glCreateShader(GL_FRAGMENT_SHADER);
      glAttachShader(programId, vertexShaderId);
      glAttachShader(programId, fragmentShaderId);

      loadVertexShader(vertexShaderId);
      loadFragmentShader(fragmentShaderId);

      glLinkProgram(programId);

      return programId;
   }

   private void loadVertexShader(int vertexShaderId) {
      glShaderSource(vertexShaderId, VERTEX_SHADER);
      glCompileShader(vertexShaderId);
      System.out.println("Validating vertex shader");
      validateShader(vertexShaderId);
   }

   private void loadFragmentShader(int fragmentShaderId) {
      glShaderSource(fragmentShaderId, FRAGMENT_SHADER);
      glCompileShader(fragmentShaderId);
      System.out.println("Validating fragment shader");
      validateShader(fragmentShaderId);
   }

   private static void validateShader(int shader) {
      int compileStatus = glGetObjectParameteriARB(shader,
            GL_OBJECT_COMPILE_STATUS_ARB);
      if (compileStatus == GL_TRUE) {
         System.out.println("Shader compiled!");
      } else {
         System.err.println(getLogInfo(shader));
         System.exit(0);
      }
   }

   private static String getLogInfo(int obj) {
      return glGetInfoLogARB(obj,
            glGetObjectParameteriARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB));
   }

}


1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200   201   202   203   204   205   206   207   208   209   210   211   212   213   214   215   216   217   218   219   220   221   222   223   224   225   226   227   228   229   230   231   232   233   234   235   236   237   238   239   240   241   242   243   244   245   246   247   248   249   250   251   252   253   254   255   256   257   258   259   260   261   262   263   264   265   266   267   268   269   270   271   272   273   274   275   276   277   278   279   280   281   282   283   284   285   286   287   288   289   290   291   292   293   294   295   296   297   298   299   300   301   302   303   304   305   306   307   308   309   310   311   312   313   314   315   316   317   318   319   320   321   322   323   324   325   326   327   328   329   330   331   332   333   334   335   336   337   338   339   340   341   342   343   344   345   346   347   348   349   350   351   352   353   354   355   356   357   358   359   360   361   362   363   364   365   366   367   368   369   370   371   372   373   374   375   376   377   378   379   380   381   382   383   384   385   386   387   388   389   390   391   392   393   394   395   396   397   398   399   400  
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.test;

/**
 * Precomputed Atmospheric Scattering
 * Copyright (c) 2008 INRIA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */
/**
 * A 4x4 matrix.
 */
public class Mat4
{

    public double[][] m = new double[ 4 ][ 4 ];
    public double[] _m = new double[ 16 ];

    /**
     * Creates a new, uninitialized matrix.
     */
    public Mat4()
    {

    }

    /**
     * Creates a new matrix with the given components. The first index is the
     * row index, the second one is the column index.
     */
    public Mat4( double m00, double m01, double m02, double m03,
            double m10, double m11, double m12, double m13,
            double m20, double m21, double m22, double m23,
            double m30, double m31, double m32, double m33 )
    {
        m[0][0] = _m[0] = m00;
        m[0][1] = _m[1] = m01;
        m[0][2] = _m[2] = m02;
        m[0][3] = _m[3] = m03;
        m[1][0] = _m[4] = m10;
        m[1][1] = _m[5] = m11;
        m[1][2] = _m[6] = m12;
        m[1][3] = _m[7] = m13;
        m[2][0] = _m[8] = m20;
        m[2][1] = _m[9] = m21;
        m[2][2] = _m[10] = m22;
        m[2][3] = _m[11] = m23;
        m[3][0] = _m[12] = m30;
        m[3][1] = _m[13] = m31;
        m[3][2] = _m[14] = m32;
        m[3][3] = _m[15] = m33;
    }

    @Override
    public String toString()
    {
        String ret = "\n";
        for( int i = 0; i < _m.length; i++ )
        {
            if( i > 0 && i % 4 == 0 )
            {
                ret += "\n";
            }
            ret += "\t" + _m[i];
        }
        return ret;
    }

    /**
     * Returns the coefficients of this matrix.
     */
    public double[] coefficients()
    {
        double[] ret = new double[ 16 ];
        System.arraycopy( _m, 0, ret, 0, _m.length );
        return ret;
    }

    public float[] coefficientsF()
    {
        float[] ret = new float[ 16 ];
        for( int i = 0; i < _m.length; i++ )
        {
            ret[i] = (float) _m[i];
        }
        return ret;
    }

    /**
     * Returns the row of this matrix whose index is given.
     */
    public double[] getRow( int row )
    {
        return m[row];
    }

    /**
     * Returns true is this matrix is different from the given matrix.
     */
    public boolean notEqual( Mat4 m2 )
    {
        if( m[0][0] != m2.m[0][0] || m[0][1] != m2.m[0][1] || m[0][2] != m2.m[0][2] || m[0][3] != m2.m[0][3] ||
                m[1][0] != m2.m[1][0] || m[1][1] != m2.m[1][1] || m[1][2] != m2.m[1][2] || m[1][3] != m2.m[1][3] ||
                m[2][0] != m2.m[2][0] || m[2][1] != m2.m[2][1] || m[2][2] != m2.m[2][2] || m[2][3] != m2.m[2][3] ||
                m[3][0] != m2.m[3][0] || m[3][1] != m2.m[3][1] || m[3][2] != m2.m[3][2] || m[3][3] != m2.m[3][3] )
        {
            return true;
        }

        return false;
    }

    /**
     * Returns the sum of this matrix and of the given matrix.
     */
    public Mat4 sum( Mat4 m2 )
    {
        Mat4 r = new Mat4();

        r._m[0] = r.m[0][0] = m[0][0] + m2.m[0][0];
        r._m[1] = r.m[0][1] = m[0][1] + m2.m[0][1];
        r._m[2] = r.m[0][2] = m[0][2] + m2.m[0][2];
        r._m[3] = r.m[0][3] = m[0][3] + m2.m[0][3];

        r._m[4] = r.m[1][0] = m[1][0] + m2.m[1][0];
        r._m[5] = r.m[1][1] = m[1][1] + m2.m[1][1];
        r._m[6] = r.m[1][2] = m[1][2] + m2.m[1][2];
        r._m[7] = r.m[1][3] = m[1][3] + m2.m[1][3];

        r._m[8] = r.m[2][0] = m[2][0] + m2.m[2][0];
        r._m[9] = r.m[2][1] = m[2][1] + m2.m[2][1];
        r._m[10] = r.m[2][2] = m[2][2] + m2.m[2][2];
        r._m[11] = r.m[2][3] = m[2][3] + m2.m[2][3];

        r._m[12] = r.m[3][0] = m[3][0] + m2.m[3][0];
        r._m[13] = r.m[3][1] = m[3][1] + m2.m[3][1];
        r._m[14] = r.m[3][2] = m[3][2] + m2.m[3][2];
        r._m[15] = r.m[3][3] = m[3][3] + m2.m[3][3];

        return r;
    }

    /**
     * Returns the difference of this matrix and of the given matrix.
     */
    public Mat4 difference( Mat4 m2 )
    {
        Mat4 r = new Mat4();
        r._m[0] = r.m[0][0] = m[0][0] - m2.m[0][0];
        r._m[1] = r.m[0][1] = m[0][1] - m2.m[0][1];
        r._m[2] = r.m[0][2] = m[0][2] - m2.m[0][2];
        r._m[3] = r.m[0][3] = m[0][3] - m2.m[0][3];

        r._m[4] = r.m[1][0] = m[1][0] - m2.m[1][0];
        r._m[5] = r.m[1][1] = m[1][1] - m2.m[1][1];
        r._m[6] = r.m[1][2] = m[1][2] - m2.m[1][2];
        r._m[7] = r.m[1][3] = m[1][3] - m2.m[1][3];

        r._m[8] = r.m[2][0] = m[2][0] - m2.m[2][0];
        r._m[9] = r.m[2][1] = m[2][1] - m2.m[2][1];
        r._m[10] = r.m[2][2] = m[2][2] - m2.m[2][2];
        r._m[11] = r.m[2][3] = m[2][3] - m2.m[2][3];

        r._m[12] = r.m[3][0] = m[3][0] - m2.m[3][0];
        r._m[13] = r.m[3][1] = m[3][1] - m2.m[3][1];
        r._m[14] = r.m[3][2] = m[3][2] - m2.m[3][2];
        r._m[15] = r.m[3][3] = m[3][3] - m2.m[3][3];

        return r;
    }

    /**
     * Returns the product of this matrix and of the given matrix.
     */
    public Mat4 product( Mat4 m2 )
    {
        Mat4 r = new Mat4();
        r._m[0] = r.m[0][0] = m[0][0] * m2.m[0][0] + m[0][1] * m2.m[1][0] + m[0][2] * m2.m[2][0] + m[0][3] * m2.m[3][0];
        r._m[1] = r.m[0][1] = m[0][0] * m2.m[0][1] + m[0][1] * m2.m[1][1] + m[0][2] * m2.m[2][1] + m[0][3] * m2.m[3][1];
        r._m[2] = r.m[0][2] = m[0][0] * m2.m[0][2] + m[0][1] * m2.m[1][2] + m[0][2] * m2.m[2][2] + m[0][3] * m2.m[3][2];
        r._m[3] = r.m[0][3] = m[0][0] * m2.m[0][3] + m[0][1] * m2.m[1][3] + m[0][2] * m2.m[2][3] + m[0][3] * m2.m[3][3];

        r._m[4] = r.m[1][0] = m[1][0] * m2.m[0][0] + m[1][1] * m2.m[1][0] + m[1][2] * m2.m[2][0] + m[1][3] * m2.m[3][0];
        r._m[5] = r.m[1][1] = m[1][0] * m2.m[0][1] + m[1][1] * m2.m[1][1] + m[1][2] * m2.m[2][1] + m[1][3] * m2.m[3][1];
        r._m[6] = r.m[1][2] = m[1][0] * m2.m[0][2] + m[1][1] * m2.m[1][2] + m[1][2] * m2.m[2][2] + m[1][3] * m2.m[3][2];
        r._m[7] = r.m[1][3] = m[1][0] * m2.m[0][3] + m[1][1] * m2.m[1][3] + m[1][2] * m2.m[2][3] + m[1][3] * m2.m[3][3];

        r._m[8] = r.m[2][0] = m[2][0] * m2.m[0][0] + m[2][1] * m2.m[1][0] + m[2][2] * m2.m[2][0] + m[2][3] * m2.m[3][0];
        r._m[9] = r.m[2][1] = m[2][0] * m2.m[0][1] + m[2][1] * m2.m[1][1] + m[2][2] * m2.m[2][1] + m[2][3] * m2.m[3][1];
        r._m[10] = r.m[2][2] = m[2][0] * m2.m[0][2] + m[2][1] * m2.m[1][2] + m[2][2] * m2.m[2][2] + m[2][3] * m2.m[3][2];
        r._m[11] = r.m[2][3] = m[2][0] * m2.m[0][3] + m[2][1] * m2.m[1][3] + m[2][2] * m2.m[2][3] + m[2][3] * m2.m[3][3];

        r._m[12] = r.m[3][0] = m[3][0] * m2.m[0][0] + m[3][1] * m2.m[1][0] + m[3][2] * m2.m[2][0] + m[3][3] * m2.m[3][0];
        r._m[13] = r.m[3][1] = m[3][0] * m2.m[0][1] + m[3][1] * m2.m[1][1] + m[3][2] * m2.m[2][1] + m[3][3] * m2.m[3][1];
        r._m[14] = r.m[3][2] = m[3][0] * m2.m[0][2] + m[3][1] * m2.m[1][2] + m[3][2] * m2.m[2][2] + m[3][3] * m2.m[3][2];
        r._m[15] = r.m[3][3] = m[3][0] * m2.m[0][3] + m[3][1] * m2.m[1][3] + m[3][2] * m2.m[2][3] + m[3][3] * m2.m[3][3];

        return r;
    }

    /**
     * Returns the product of this matrix and of the given vector. The given
     * vector w coordinate is set to 1, and the 4 vector result is converted
     * to a 3 vector by dividing its xyz components by its w component.
     */
    public Vec3 product( Vec3 v )
    {
        Vec3 r = new Vec3();

        double fInvW = 1.0 / ( m[3][0] * v.x + m[3][1] * v.y + m[3][2] * v.z + m[3][3] );

        r.x = ( m[0][0] * v.x + m[0][1] * v.y + m[0][2] * v.z + m[0][3] ) * fInvW;
        r.y = ( m[1][0] * v.x + m[1][1] * v.y + m[1][2] * v.z + m[1][3] ) * fInvW;
        r.z = ( m[2][0] * v.x + m[2][1] * v.y + m[2][2] * v.z + m[2][3] ) * fInvW;

        return r;

    }

    /**
     * Returns the product of this matrix and of the given scalar.
     */
    public Mat4 product( double f )
    {
        Mat4 r = new Mat4();

        r._m[0] = r.m[0][0] = m[0][0] * f;
        r._m[1] = r.m[0][1] = m[0][1] * f;
        r._m[2] = r.m[0][2] = m[0][2] * f;
        r._m[3] = r.m[0][3] = m[0][3] * f;

        r._m[4] = r.m[1][0] = m[1][0] * f;
        r._m[5] = r.m[1][1] = m[1][1] * f;
        r._m[6] = r.m[1][2] = m[1][2] * f;
        r._m[7] = r.m[1][3] = m[1][3] * f;

        r._m[8] = r.m[2][0] = m[2][0] * f;
        r._m[9] = r.m[2][1] = m[2][1] * f;
        r._m[10] = r.m[2][2] = m[2][2] * f;
        r._m[11] = r.m[2][3] = m[2][3] * f;

        r._m[12] = r.m[3][0] = m[3][0] * f;
        r._m[13] = r.m[3][1] = m[3][1] * f;
        r._m[14] = r.m[3][2] = m[3][2] * f;
        r._m[15] = r.m[3][3] = m[3][3] * f;

        return r;
    }

    /**
     * Returns the transpose of this matrix.
     */
    public Mat4 transpose()
    {
        return new Mat4( m[0][0], m[1][0], m[2][0], m[3][0],
                m[0][1], m[1][1], m[2][1], m[3][1],
                m[0][2], m[1][2], m[2][2], m[3][2],
                m[0][3], m[1][3], m[2][3], m[3][3] );

    }

    private double MINOR( final Mat4 mat, int r0, int r1, int r2, int c0, int c1, int c2 )
    {
        return mat.m[r0][c0] * ( mat.m[r1][c1] * mat.m[r2][c2] - mat.m[r2][c1] * mat.m[r1][c2] ) -
                mat.m[r0][c1] * ( mat.m[r1][c0] * mat.m[r2][c2] - mat.m[r2][c0] * mat.m[r1][c2] ) +
                mat.m[r0][c2] * ( mat.m[r1][c0] * mat.m[r2][c1] - mat.m[r2][c0] * mat.m[r1][c1] );
    }

    /**
     * Returns the adjoint of this matrix.
     */
    public Mat4 adjoint()
    {
        return new Mat4( MINOR( this, 1, 2, 3, 1, 2, 3 ),
                -MINOR( this, 0, 2, 3, 1, 2, 3 ),
                MINOR( this, 0, 1, 3, 1, 2, 3 ),
                -MINOR( this, 0, 1, 2, 1, 2, 3 ),
                -MINOR( this, 1, 2, 3, 0, 2, 3 ),
                MINOR( this, 0, 2, 3, 0, 2, 3 ),
                -MINOR( this, 0, 1, 3, 0, 2, 3 ),
                MINOR( this, 0, 1, 2, 0, 2, 3 ),
                MINOR( this, 1, 2, 3, 0, 1, 3 ),
                -MINOR( this, 0, 2, 3, 0, 1, 3 ),
                MINOR( this, 0, 1, 3, 0, 1, 3 ),
                -MINOR( this, 0, 1, 2, 0, 1, 3 ),
                -MINOR( this, 1, 2, 3, 0, 1, 2 ),
                MINOR( this, 0, 2, 3, 0, 1, 2 ),
                -MINOR( this, 0, 1, 3, 0, 1, 2 ),
                MINOR( this, 0, 1, 2, 0, 1, 2 ) );

    }

    /**
     * Returns the inverse of this matrix.
     */
    public Mat4 inverse()
    {
        return adjoint().product( 1.0f / determinant() );

    }

    /**
     * Returns the determinant of this matrix.
     */
    public double determinant()
    {
        return m[0][0] * MINOR( this, 1, 2, 3, 1, 2, 3 ) -
                m[0][1] * MINOR( this, 1, 2, 3, 0, 2, 3 ) +
                m[0][2] * MINOR( this, 1, 2, 3, 0, 1, 3 ) -
                m[0][3] * MINOR( this, 1, 2, 3, 0, 1, 2 );

    }

    /**
     * Returns the translation matrix corresponding to the given translation
     * vector.
     */
    public static Mat4 translate( final Vec3 v )
    {
        return new Mat4( 1, 0, 0, v.x,
                0, 1, 0, v.y,
                0, 0, 1, v.z,
                0, 0, 0, 1 );

    }

    /**
     * Returns the perspective projection matrix corresponding to the given
     * projection parameters.
     *
     * @param fovy vertical field of view in degrees.
     * @param aspect aspect ratio of the projection window.
     * @param zNear near clipping plane.
     * @param zFar far clipping plane.
     */
    public static Mat4 perspectiveProjection( double fovy, double aspect, double zNear, double zFar )
    {
        double f = 1.0 / Math.tan( fovy / 2 );

        return new Mat4( f / aspect, 0, 0, 0,
                0, f, 0, 0,
                0, 0, ( zFar + zNear ) / ( zNear - zFar ), ( 2 * zFar * zNear ) / ( zNear - zFar ),
                0, 0, -1, 0 );

    }

    @Override
    public boolean equals( Object obj )
    {
        if( obj instanceof Mat4 )
        {
            Mat4 m2 = (Mat4) obj;
            if( m[0][0] != m2.m[0][0] || m[0][1] != m2.m[0][1] || m[0][2] != m2.m[0][2] || m[0][3] != m2.m[0][3] ||
                    m[1][0] != m2.m[1][0] || m[1][1] != m2.m[1][1] || m[1][2] != m2.m[1][2] || m[1][3] != m2.m[1][3] ||
                    m[2][0] != m2.m[2][0] || m[2][1] != m2.m[2][1] || m[2][2] != m2.m[2][2] || m[2][3] != m2.m[2][3] ||
                    m[3][0] != m2.m[3][0] || m[3][1] != m2.m[3][1] || m[3][2] != m2.m[3][2] || m[3][3] != m2.m[3][3] )
            {
                return false;
            }

            return true;
        }
        return false;
    }

    @Override
    public int hashCode()
    {
        int hash = 5;
        hash = 73 * hash + ( this.m != null ? this.m.hashCode() : 0 );
        hash = 73 * hash + ( this._m != null ? this._m.hashCode() : 0 );
        return hash;
    }
}


1   2   3   4   5   6   7   8   9   10   11   12   13   14   15   16   17   18   19   20   21   22   23   24   25   26   27   28   29   30   31   32   33   34   35   36   37   38   39   40   41   42   43   44   45   46   47   48   49   50   51   52   53   54   55   56   57   58   59   60   61   62   63   64   65   66   67   68   69   70   71   72   73   74   75   76   77   78   79   80   81   82   83   84   85   86   87   88   89   90   91   92   93   94   95   96   97   98   99   100   101   102   103   104   105   106   107   108   109   110   111   112   113   114   115   116   117   118   119   120   121   122   123   124   125   126   127   128   129   130   131   132   133   134   135   136   137   138   139   140   141   142   143   144   145   146   147   148   149   150   151   152   153   154   155   156   157   158   159   160   161   162   163   164   165   166   167   168   169   170   171   172   173   174   175   176   177   178   179   180   181   182   183   184   185   186   187   188   189   190   191   192   193   194   195   196   197   198   199   200   201   202   203   204   205   206   207   208   209   210   211   212   213   214   215   216   217   218   219   220   221   222   223   224   225   226   227   228   229   230   231   232   233   234   235   236   237   238   239   240   241   242   243   244   245   246   247   248   249   250   251   252   253   254   255   256   257   258   259   260   261   262   263   264   265   266   267   268   269   270   271   272   273   274   275   276   277   278   279   280   281   282   283   284   285   286   287   288   289   290   291   292   293   294   295   296   297   298   299   300   301   302   303   304   305   306   307   308   309   310   311   312   313   314   315   316   317   318   319   320   321   322   323   324   325   326   327   328   329   330   331   332   333   334   335   336   337   338   339   340   341  
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.test;

/**
 * Precomputed Atmospheric Scattering
 * Copyright (c) 2008 INRIA
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. Neither the name of the copyright holders nor the names of its
 *    contributors may be used to endorse or promote products derived from
 *    this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
 * THE POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * A 3D vector.
 */
public class Vec3
{

    /**
     * The null vector (0,0,0).
     */
    public static final Vec3 ZERO = new Vec3( 0.0, 0.0, 0.0 );
    /**
     * The unit x vector (1,0,0).
     */
    public static final Vec3 UNIT_X = new Vec3( 1.0, 0.0, 0.0 );
    /**
     * The unit y vector (0,1,0).
     */
    public static final Vec3 UNIT_Y = new Vec3( 0.0, 1.0, 0.0 );
    /**
     * The unit z vector (0,0,1).
     */
    public static final Vec3 UNIT_Z = new Vec3( 0.0, 0.0, 1.0 );
    public double x,  y,  z;

    /**
     * Creates a new, uninitialized vector.
     */
    public Vec3()
    {

    }

    /**
     * Creates a new vector with the given coordinates.
     */
    public Vec3( double xi, double yi, double zi )
    {
        assign( xi, yi, zi );
    }

    /**
     * Creates a new vector with the given coordinates.
     */
    public Vec3( double[] v )
    {
        if( v.length >= 3 )
        {
            assign( v[0], v[1], v[2] );
        }
    }

    /**
     * Creates a new vector as a copy of the given vector.
     */
    public Vec3( Vec3 v )
    {
        assign( v.x, v.y, v.z );
    }

    @Override
    public String toString()
    {
        return "Vec3( " + x + ", " + y + ", " + z + " )";
    }

    /**
     * Returns the coordinate of this vector whose index is given.
     */
    public double get( int index )
    {
        if( index == 0 )
        {
            return x;
        }
        else if( index == 1 )
        {
            return y;
        }
        else if( index == 2 )
        {
            return z;
        }
        return Double.MAX_VALUE;
    }

    /**
     * Assigns the given vector to this vector.
     */
    public void assign( Vec3 v )
    {
        assign( v.x, v.y, v.z );
    }

    public void assign( double x, double y, double z )
    {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    /**
     * Returns true if this vector is equal to the given vector.
     */
    @Override
    public boolean equals( Object obj )
    {
        if( obj instanceof Vec3 )
        {
            Vec3 v = (Vec3) obj;
            return ( x == v.x && y == v.y && z == v.z );
        }
        return false;
    }

    /**
     * Returns true if this vector is different from the given vector.
     */
    public boolean notEqual( final Vec3 v )
    {
        return ( x != v.x || y != v.y || z != v.z );
    }

    /**
     * Returns the sum of this vector and of the given vector.
     */
    public Vec3 sum( final Vec3 v )
    {
        return new Vec3( x + v.x, y + v.y, z + v.z );
    }

    /**
     * Returns the difference of this vector and of the given vector.
     */
    public Vec3 difference( final Vec3 v )
    {
        return new Vec3( x - v.x, y - v.y, z - v.z );
    }

    /**
     * Returns the product of this vector and of the given vector. The
     * product is done component by component.
     */
    public Vec3 product( final Vec3 v )
    {
        return new Vec3( x * v.x, y * v.y, z * v.z );

    }

    /**
     * Returns the product of this vector and of the given scalar.
     */
    public Vec3 product( final double scalar )
    {
        return new Vec3( x * scalar, y * scalar, z * scalar );

    }

    /**
     * Returns the division of this vector and of the given vector. The
     * division is done component by component.
     */
    public Vec3 divide( final Vec3 v )
    {
        return new Vec3( x / v.x, y / v.y, z / v.z );

    }

    /**
     * Returns the division of this vector and of the given scalar.
     */
    public Vec3 divide( double scalar ) throws Exception
    {
        if( scalar != 0 )
        {
            double inv = 1 / scalar;
            return new Vec3( x * inv, y * inv, z * inv );
        }
        throw new Exception( "Division by zero" );

    }

    /**
     * Returns the opposite of this vector.
     */
    public Vec3 negate()
    {
        return new Vec3( -x, -y, -z );

    }

    /**
     * Adds the given vector to this vector.
     */
    public Vec3 addAssign( final Vec3 v )
    {
        x += v.x;
        y += v.y;
        z += v.z;
        return this;
    }

    /**
     * Substracts the given vector from this vector.
     */
    public Vec3 subtractAssign( final Vec3 v )
    {
        x -= v.x;
        y -= v.y;
        z -= v.z;
        return this;

    }

    /**
     * Multiplies this vector by the given scalar.
     */
    public Vec3 multiplyAssign( final double scalar )
    {
        x *= scalar;
        y *= scalar;
        z *= scalar;
        return this;

    }

    /**
     * Divides this vector by the given scalar.
     */
    public Vec3 divideAssign( final double scalar ) throws Exception
    {
        if( scalar != 0 )
        {
            double inv = 1 / scalar;
            x *= inv;
            y *= inv;
            z *= inv;
            return this;
        }
        throw new Exception( "Division by zero" );
    }

    /**
     * Returns the length of this vector.
     */
    public double length()
    {
        return Math.sqrt( x * x + y * y + z * z );

    }

    /**
     * Returns the squared length of this vector.
     */
    public double squaredLength()
    {
        return ( x * x + y * y + z * z );

    }

    /**
     * Returns the dot product of this vector and of the given vector.
     */
    public double dotProduct( final Vec3 v )
    {
        return ( x * v.x + y * v.y + z * v.z );

    }

    /**
     * Normalizes this vector and returns its initial length.
     */
    public double normalise()
    {
        double length = Math.sqrt( x * x + y * y + z * z );
        double invLength = 1.0 / length;
        x *= invLength;
        y *= invLength;
        z *= invLength;
        return length;

    }

    /**
     * Normalizes this vector to the given length and returns its initial length.
     */
    public double normalise( double len )
    {
        double length = Math.sqrt( x * x + y * y + z * z );
        double invLength = len / length;
        x *= invLength;
        y *= invLength;
        z *= invLength;
        return length;

    }

    /**
     * Returns he cross product of this vector and of the given vector.
     */
    public Vec3 crossProduct( final Vec3 v )
    {
        return new Vec3( y * v.z - z * v.y, z * v.x - x * v.z, x * v.y - y * v.x );

    }
}





Dump your java code here :



Special syntax:
  • To highlight a line (yellow background), prefix it with '@@'
  • To indicate that a line should be removed (red background), prefix it with '-'
  • To indicate that a line should be added (green background), prefix it with '+'
  • To post multiple snippets, seperate them by '~~~~'
  EOF
 
DesertCoockie (36 views)
2018-05-13 18:23:11

nelsongames (81 views)
2018-04-24 18:15:36

nelsongames (73 views)
2018-04-24 18:14:32

ivj94 (755 views)
2018-03-24 14:47:39

ivj94 (85 views)
2018-03-24 14:46:31

ivj94 (626 views)
2018-03-24 14:43:53

Solater (101 views)
2018-03-17 05:04:08

nelsongames (182 views)
2018-03-05 17:56:34

Gornova (408 views)
2018-03-02 22:15:33

buddyBro (1068 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!