Package fcagnin.jglsdk.glm

Examples of fcagnin.jglsdk.glm.Vec4


        return Quaternion.add( Quaternion.scale( v0, (float) Math.cos( theta ) ),
                Quaternion.scale( v2, (float) Math.sin( theta ) ) );
    }

    private Quaternion lerp(Quaternion v0, Quaternion v1, float alpha) {
        Vec4 start = vectorize( v0 );
        Vec4 end = vectorize( v1 );
        Vec4 interp = Glm.mix( start, end, alpha );

        System.out.printf( "alpha: %f, (%f, %f, %f, %f)\n", alpha, interp.w, interp.x, interp.y, interp.z );

        interp = Glm.normalize( interp );
        return new Quaternion( interp.w, interp.x, interp.y, interp.z );
View Full Code Here


        interp = Glm.normalize( interp );
        return new Quaternion( interp.w, interp.x, interp.y, interp.z );
    }

    private Vec4 vectorize(Quaternion theQuat) {
        Vec4 vec = new Vec4();
        vec.x = theQuat.x;
        vec.y = theQuat.y;
        vec.z = theQuat.z;
        vec.w = theQuat.w;
        return vec;
View Full Code Here

        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 currMatrix = new MatrixStack();
        currMatrix.translate( 0.0f, 0.0f, -200.0f );
        currMatrix.rotateX( gimbalAngles.angleX );
        drawGimbal( currMatrix, GimbalAxis.X_AXIS, new Vec4( 0.4f, 0.4f, 1.0f, 1.0f ) );
        currMatrix.rotateY( gimbalAngles.angleY );
        drawGimbal( currMatrix, GimbalAxis.Y_AXIS, new Vec4( 0.0f, 1.0f, 0.0f, 1.0f ) );
        currMatrix.rotateZ( gimbalAngles.angleZ );
        drawGimbal( currMatrix, GimbalAxis.Z_AXIS, new Vec4( 1.0f, 0.3f, 0.3f, 1.0f ) );

        glUseProgram( theProgram );

        currMatrix.scale( 3.0f, 3.0f, 3.0f );
        currMatrix.rotateX( -90.0f );
View Full Code Here

        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

    }
   
   
    public Mat4 calcMatrix() {
      Mat4 translateMat = new Mat4(1.0f);
      translateMat.setColumn(3, new Vec4(m_po.position, 1.0f));

      return translateMat.mul(Glm.matCast(m_po.orientation));
    }
View Full Code Here

    @Override
    protected void display() {
        lights.updateTime( getElapsedTime() );

        Vec4 bkg = lights.getBackgroundColor();

        glClearColor( bkg.x, bkg.y, bkg.z, bkg.w );
        glClearDepth( 1.0f );
        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 );

        {
            modelMatrix.push();

            scene.draw( modelMatrix, materialBlockIndex, lights.getTimerValue( "tetra" ) );

            modelMatrix.pop();
        }

        {
            modelMatrix.push();

            // Render the sun
            {
                modelMatrix.push();

                Vec3 sunlightDir = new Vec3( lights.getSunlightDirection() );
                modelMatrix.translate( sunlightDir.scale( 500.0f ) );
                modelMatrix.scale( 30.0f, 30.0f, 30.0f );

                glUseProgram( unlit.theProgram );
                glUniformMatrix4( unlit.modelToCameraMatrixUnif, false,
                        modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );

                Vec4 lightColor = lights.getSunlightIntensity();
                glUniform4( unlit.objectColorUnif, lightColor.fillAndFlipBuffer( vec4Buffer ) );
                scene.getSphereMesh().render( "flat" );

                modelMatrix.pop();
            }

            // Render the lights
            {
                for ( int light = 0; light < lights.getNumberOfPointLights(); light++ ) {
                    modelMatrix.push();

                    modelMatrix.translate( lights.getWorldLightPosition( light ) );

                    glUseProgram( unlit.theProgram );
                    glUniformMatrix4( unlit.modelToCameraMatrixUnif, false,
                            modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );

                    Vec4 lightColor = lights.getPointLightIntensity( light );
                    glUniform4( unlit.objectColorUnif, lightColor.fillAndFlipBuffer( vec4Buffer ) );
                    scene.getCubeMesh().render( "flat" );

                    modelMatrix.pop();
                }
            }
View Full Code Here

    private void setupDaytimeLighting() {
        SunlightValue values[] = {
                new SunlightValue(
                        0.0f / 24.0f,
                        new Vec4( 0.2f, 0.2f, 0.2f, 1.0f ),
                        new Vec4( 0.6f, 0.6f, 0.6f, 1.0f ),
                        new Vec4( skyDaylightColor ) ),
                new SunlightValue(
                        4.5f / 24.0f,
                        new Vec4( 0.2f, 0.2f, 0.2f, 1.0f ),
                        new Vec4( 0.6f, 0.6f, 0.6f, 1.0f ),
                        new Vec4( skyDaylightColor ) ),
                new SunlightValue(
                        6.5f / 24.0f,
                        new Vec4( 0.15f, 0.05f, 0.05f, 1.0f ),
                        new Vec4( 0.3f, 0.1f, 0.10f, 1.0f ),
                        new Vec4( 0.5f, 0.1f, 0.1f, 1.0f ) ),
                new SunlightValue(
                        8.0f / 24.0f,
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ),
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ),
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ) ),
                new SunlightValue(
                        18.0f / 24.0f,
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ),
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ),
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ) ),
                new SunlightValue(
                        19.5f / 24.0f,
                        new Vec4( 0.15f, 0.05f, 0.05f, 1.0f ),
                        new Vec4( 0.3f, 0.1f, 0.1f, 1.0f ),
                        new Vec4( 0.5f, 0.1f, 0.1f, 1.0f ) ),
                new SunlightValue(
                        20.5f / 24.0f,
                        new Vec4( 0.2f, 0.2f, 0.2f, 1.0f ),
                        new Vec4( 0.6f, 0.6f, 0.6f, 1.0f ),
                        new Vec4( skyDaylightColor ) )
        };

        lights.setSunlightValues( values, 7 );

        lights.setPointLightIntensity( 0, new Vec4( 0.2f, 0.2f, 0.2f, 1.0f ) );
        lights.setPointLightIntensity( 1, new Vec4( 0.0f, 0.0f, 0.3f, 1.0f ) );
        lights.setPointLightIntensity( 2, new Vec4( 0.3f, 0.0f, 0.0f, 1.0f ) );
    }
View Full Code Here

    private void setupNighttimeLighting() {
        SunlightValue values[] = {
                new SunlightValue(
                        0.0f / 24.0f,
                        new Vec4( 0.2f, 0.2f, 0.2f, 1.0f ),
                        new Vec4( 0.6f, 0.6f, 0.6f, 1.0f ),
                        new Vec4( skyDaylightColor ) ),
                new SunlightValue(
                        4.5f / 24.0f,
                        new Vec4( 0.2f, 0.2f, 0.2f, 1.0f ),
                        new Vec4( 0.6f, 0.6f, 0.6f, 1.0f ),
                        new Vec4( skyDaylightColor ) ),
                new SunlightValue(
                        6.5f / 24.0f,
                        new Vec4( 0.15f, 0.05f, 0.05f, 1.0f ),
                        new Vec4( 0.3f, 0.1f, 0.10f, 1.0f ),
                        new Vec4( 0.5f, 0.1f, 0.1f, 1.0f ) ),
                new SunlightValue(
                        8.0f / 24.0f,
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ),
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ),
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ) ),
                new SunlightValue(
                        18.0f / 24.0f,
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ),
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ),
                        new Vec4( 0.0f, 0.0f, 0.0f, 1.0f ) ),
                new SunlightValue(
                        19.5f / 24.0f,
                        new Vec4( 0.15f, 0.05f, 0.05f, 1.0f ),
                        new Vec4( 0.3f, 0.1f, 0.1f, 1.0f ),
                        new Vec4( 0.5f, 0.1f, 0.1f, 1.0f ) ),
                new SunlightValue(
                        20.5f / 24.0f,
                        new Vec4( 0.2f, 0.2f, 0.2f, 1.0f ),
                        new Vec4( 0.6f, 0.6f, 0.6f, 1.0f ),
                        new Vec4( skyDaylightColor ) )
        };

        lights.setSunlightValues( values, 7 );

        lights.setPointLightIntensity( 0, new Vec4( 0.6f, 0.6f, 0.6f, 1.0f ) );
        lights.setPointLightIntensity( 1, new Vec4( 0.0f, 0.0f, 0.7f, 1.0f ) );
        lights.setPointLightIntensity( 2, new Vec4( 0.7f, 0.0f, 0.0f, 1.0f ) );
    }
View Full Code Here

    private abstract class Instance {
        abstract Vec3 calcOffset(float elapsedTime);

        Mat4 constructMatrix(float elapsedTime) {
            Mat4 theMat = new Mat4( 1.0f );
            theMat.setColumn( 3, new Vec4( calcOffset( elapsedTime ), 1.0f ) );

            return theMat;
        }
View Full Code Here

TOP

Related Classes of fcagnin.jglsdk.glm.Vec4

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.