Package fcagnin.jglsdk.glm

Examples of fcagnin.jglsdk.glm.Mat4


        float hOffset = (float) (Math.cos( cyclicAngle ) * 0.25f);
        float vOffset = (float) (Math.sin( cyclicAngle ) * 0.25f);

        MatrixStack modelMatrix = new MatrixStack();

        final Mat4 worldToCamMat = Glm.lookAt( new Vec3( hOffset, 1.0f, -64.0f ),
                new Vec3( hOffset, -5.0f + vOffset, -44.0f ), new Vec3( 0.0f, 1.0f, 0.0f ) );

        modelMatrix.applyMatrix( worldToCamMat );

        glUseProgram( program.theProgram );
View Full Code Here


                modelMatrix.push();
                Vec3 cameraAimVec = Vec3.sub( camTarget, camPos );
                modelMatrix.translate( 0.0f, 0.0f, -Glm.length( cameraAimVec ) );
                modelMatrix.scale( 1.0f, 1.0f, 1.0f );

                Mat4 identity = new Mat4( 1.0f );

                glUseProgram( objectColor.theProgram );
                glUniformMatrix4( objectColor.modelToWorldMatrixUnif, false,
                        modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
                glUniformMatrix4( objectColor.worldToCameraMatrixUnif, false,
                        identity.fillAndFlipBuffer( mat4Buffer ) );
                cubeColorMesh.render();
                glUseProgram( 0 );

                modelMatrix.pop();
View Full Code Here

        Vec3 upDir = Glm.normalize( upPt );

        Vec3 rightDir = Glm.normalize( Glm.cross( lookDir, upDir ) );
        Vec3 perpUpDir = Glm.cross( rightDir, lookDir );

        Mat4 rotMat = new Mat4( 1.0f );
        rotMat.setColumn( 0, new Vec4( rightDir, 0.0f ) );
        rotMat.setColumn( 1, new Vec4( perpUpDir, 0.0f ) );
        rotMat.setColumn( 2, new Vec4( Vec3.negate( lookDir ), 0.0f ) );

        rotMat = Glm.transpose( rotMat );

        Mat4 transMat = new Mat4( 1.0f );
        transMat.setColumn( 3, new Vec4( Vec3.negate( cameraPt ), 1.0f ) );

        return rotMat.mul( transMat );
    }
View Full Code Here

        Vec3 upDir = Glm.normalize( upPt );

        Vec3 rightDir = Glm.normalize( Glm.cross( lookDir, upDir ) );
        Vec3 perpUpDir = Glm.cross( rightDir, lookDir );

        Mat4 rotMat = new Mat4( 1.0f );
        rotMat.setColumn( 0, new Vec4( rightDir, 0.0f ) );
        rotMat.setColumn( 1, new Vec4( perpUpDir, 0.0f ) );
        rotMat.setColumn( 2, new Vec4( Vec3.negate( lookDir ), 0.0f ) );

        rotMat = Glm.transpose( rotMat );

        Mat4 transMat = new Mat4( 1.0f );
        transMat.setColumn( 3, new Vec4( Vec3.negate( cameraPt ), 1.0f ) );

        return rotMat.mul( transMat );
    }
View Full Code Here

        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        MatrixStack modelMatrix = new MatrixStack();
        modelMatrix.setMatrix( viewPole.calcMatrix() );

        final Mat4 worldToCamMat = modelMatrix.top();
        LightBlock lightData = lights.getLightInformation( worldToCamMat );

        glBindBuffer( GL_UNIFORM_BUFFER, lightUniformBuffer );
        glBufferSubData( GL_UNIFORM_BUFFER, 0, lightData.fillAndFlipBuffer( lightBlockBuffer ) );
        glBindBuffer( GL_UNIFORM_BUFFER, 0 );
View Full Code Here

    };

   
    @Override
    public Mat4 calcMatrix() {
      Mat4 mat = new Mat4(1.0f);

      // Remember: these transforms are in reverse order.

      // In this space, we are facing in the correct direction. Which means that the camera point
      // is directly behind us by the radius number of units.
      mat = Glm.translate(mat, new Vec3(0.0f, 0.0f, -m_currView.radius));

      // Rotate the world to look in the right direction..
      Quaternion fullRotation = Glm.angleAxis(m_currView.degSpinRotation, new Vec3(0.0f, 0.0f, 1.0f)).mul(m_currView.orient);

      mat.mul(Glm.matCast(fullRotation));

      // Translate the world by the negation of the lookat point, placing the origin at the lookat point.
      mat = Glm.translate(mat, Vec3.negate(m_currView.targetPos));

      return mat;
View Full Code Here

      Vec3 offsetDir = new Vec3(g_offsets[eDir.ordinal()]);
      offsetTargetPos(offsetDir.scale(worldDistance).scale(lastFrameDuration), lastFrameDuration);
    }

    private void offsetTargetPos(Vec3 cameraOffset, float lastFrameDuration) {
      Mat4 currMat = calcMatrix();
      Quaternion orientation = Glm.quatCast(currMat);

      Quaternion invOrient = Glm.conjugate(orientation);
      Vec3 worldOffset = invOrient.mul(cameraOffset);
View Full Code Here

  private int firstIndexUsable;
   
 
  public MatrixStack() {
    matrices = new float[160];                          // 10 matrices   
    currentMatrix = new Mat4(1.0f);
       
    firstIndexUsable = 0;
  }
View Full Code Here

    currentMatrix.mul(mat);
  }
   
 
  public void setIdentity() {
    currentMatrix = new Mat4(1.0f);
  }
View Full Code Here

  public void setIdentity() {
    currentMatrix = new Mat4(1.0f);
  }
 
  public void setMatrix(Mat4 mat) {
    currentMatrix = new Mat4(mat);
  }
View Full Code Here

TOP

Related Classes of fcagnin.jglsdk.glm.Mat4

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.