Examples of Vec3


Examples of fcagnin.jglsdk.glm.Vec3

    protected void update() {
        final float SMALL_ANGLE_INCREMENT = 9.0f;
        float lastFrameDuration = getLastFrameDuration() * 10 / 1000.0f;

        if ( Keyboard.isKeyDown( Keyboard.KEY_W ) ) {
            offsetOrientation( new Vec3( 1.0f, 0.0f, 0.0f ), SMALL_ANGLE_INCREMENT * lastFrameDuration );
        } else if ( Keyboard.isKeyDown( Keyboard.KEY_S ) ) {
            offsetOrientation( new Vec3( 1.0f, 0.0f, 0.0f ), -SMALL_ANGLE_INCREMENT * lastFrameDuration );
        }

        if ( Keyboard.isKeyDown( Keyboard.KEY_A ) ) {
            offsetOrientation( new Vec3( 0.0f, 0.0f, 1.0f ), SMALL_ANGLE_INCREMENT * lastFrameDuration );
        } else if ( Keyboard.isKeyDown( Keyboard.KEY_D ) ) {
            offsetOrientation( new Vec3( 0.0f, 0.0f, 1.0f ), -SMALL_ANGLE_INCREMENT * lastFrameDuration );
        }

        if ( Keyboard.isKeyDown( Keyboard.KEY_Q ) ) {
            offsetOrientation( new Vec3( 0.0f, 1.0f, 0.0f ), SMALL_ANGLE_INCREMENT * lastFrameDuration );
        } else if ( Keyboard.isKeyDown( Keyboard.KEY_E ) ) {
            offsetOrientation( new Vec3( 0.0f, 1.0f, 0.0f ), -SMALL_ANGLE_INCREMENT * lastFrameDuration );
        }


        while ( Keyboard.next() ) {
            if ( Keyboard.getEventKeyState() ) {
View Full Code Here

Examples of fcagnin.jglsdk.glm.Vec3

        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 );
        glUniformMatrix4( program.modelToCameraMatrixUnif, false, modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
View Full Code Here

Examples of fcagnin.jglsdk.glm.Vec3

        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
        glClearDepth( 1.0f );
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        {
            final Vec3 camPos = resolveCamPosition();

            MatrixStack camMatrix = new MatrixStack();
            camMatrix.setMatrix( calcLookAtMatrix( camPos, camTarget, new Vec3( 0.0f, 1.0f, 0.0f ) ) );

            glUseProgram( uniformColor.theProgram );
            glUniformMatrix4( uniformColor.worldToCameraMatrixUnif, false,
                    camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUseProgram( objectColor.theProgram );
            glUniformMatrix4( objectColor.worldToCameraMatrixUnif, false,
                    camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUseProgram( uniformColorTint.theProgram );
            glUniformMatrix4( uniformColorTint.worldToCameraMatrixUnif, false,
                    camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
            glUseProgram( 0 );

            MatrixStack modelMatrix = new MatrixStack();

            // Render the ground plane.
            {
                modelMatrix.push();
                modelMatrix.scale( 100.0f, 1.0f, 100.0f );

                glUseProgram( uniformColor.theProgram );
                glUniformMatrix4( uniformColor.modelToWorldMatrixUnif, false,
                        modelMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
                glUniform4f( uniformColor.baseColorUnif, 0.302f, 0.416f, 0.0589f, 1.0f );
                planeMesh.render();
                glUseProgram( 0 );

                modelMatrix.pop();
            }

            // Draw the trees.
            drawForest( modelMatrix );

            // Draw the building.
            {
                modelMatrix.push();
                modelMatrix.translate( 20.0f, 0.0f, -10.0f );

                drawParthenon( modelMatrix );

                modelMatrix.pop();
            }

            if ( drawLookatPoint ) {
                glDisable( GL_DEPTH_TEST );

                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 );
View Full Code Here

Examples of fcagnin.jglsdk.glm.Vec3

        float sinTheta = (float) Math.sin( theta );
        float cosTheta = (float) Math.cos( theta );
        float cosPhi = (float) Math.cos( phi );
        float sinPhi = (float) Math.sin( phi );

        Vec3 dirToCamera = new Vec3( sinTheta * cosPhi, cosTheta, sinTheta * sinPhi );
        return (dirToCamera.scale( sphereCamRelPos.z )).add( camTarget );
    }
View Full Code Here

Examples of fcagnin.jglsdk.glm.Vec3

        return (dirToCamera.scale( sphereCamRelPos.z )).add( camTarget );
    }


    private Mat4 calcLookAtMatrix(Vec3 cameraPt, Vec3 lookPt, Vec3 upPt) {
        Vec3 lookDir = Glm.normalize( Vec3.sub( lookPt, cameraPt ) );
        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 ) );
View Full Code Here

Examples of fcagnin.jglsdk.glm.Vec3

    protected void display() {
        glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
        glClearDepth( 1.0f );
        glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

        final Vec3 camPos = resolveCamPosition();

        MatrixStack camMatrix = new MatrixStack();
        camMatrix.setMatrix( calcLookAtMatrix( camPos, camTarget, new Vec3( 0.0f, 1.0f, 0.0f ) ) );

        glBindBuffer( GL_UNIFORM_BUFFER, globalMatricesUBO );
        glBufferSubData( GL_UNIFORM_BUFFER, Mat4.SIZE, camMatrix.top().fillAndFlipBuffer( mat4Buffer ) );
        glBindBuffer( GL_UNIFORM_BUFFER, 0 );
View Full Code Here

Examples of fcagnin.jglsdk.glm.Vec3

        float sinTheta = (float) Math.sin( theta );
        float cosTheta = (float) Math.cos( theta );
        float cosPhi = (float) Math.cos( phi );
        float sinPhi = (float) Math.sin( phi );

        Vec3 dirToCamera = new Vec3( sinTheta * cosPhi, cosTheta, sinTheta * sinPhi );
        return (dirToCamera.scale( sphereCamRelPos.z )).add( camTarget );
    }
View Full Code Here

Examples of fcagnin.jglsdk.glm.Vec3

        return (dirToCamera.scale( sphereCamRelPos.z )).add( camTarget );
    }


    private Mat4 calcLookAtMatrix(Vec3 cameraPt, Vec3 lookPt, Vec3 upPt) {
        Vec3 lookDir = Glm.normalize( Vec3.sub( lookPt, cameraPt ) );
        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 ) );
View Full Code Here

Examples of net.minecraft.src.Vec3

        // TODO: figure out why the heck this is required for Stella's Hydras...
        // TODO: rename this gameSetting to "hydraXRotationSkew" or other sensible name
        rawY += rawZ * MathHelper.sin(vrSettings.posTrackHydraYAxisDistanceSkewAngleDeg*PIOVER180 );
       
        //Raw is the absolute coordinate in hydra reference frame of the sample (possible average of two controllers)
        Vec3 raw = Vec3.createVectorHelper(rawX, rawY, rawZ);
       
        //Rel is the relative coordinate in hydra reference frame
        Vec3 rel = origin.subtract(raw);
       
        //Account for hydra base station / head tracker orientation not aligned
        //After this, rel is in body coordinates (relative to head tracker reference frame, not accounting for mouse-induced world yaw offset)
        rel.rotateAroundY(baseStationYawOffset*PIOVER180);

        //Now, compute the offset from the hydra controller to the camera location. Straight from the settings (although negated -
        //vrSettings stores eye center -> hydra values for user readability. We need hydra -> eye center values here)
        float hydraXOffset = -vrSettings.getPosTrackHydraOffsetX();
        float hydraYOffset = -vrSettings.getPosTrackHydraOffsetY();
        float hydraZOffset = vrSettings.getPosTrackHydraOffsetZ();

        // The configured offset is for a 0,0,0 rotation head. Apply current head orientation to get final offset
        Vec3 correctionToCentreEyePosition = Vec3.createVectorHelper(hydraXOffset, hydraYOffset, hydraZOffset);

        correctionToCentreEyePosition.rotateAroundZ(rollHeadDegrees*PIOVER180);
        correctionToCentreEyePosition.rotateAroundX(pitchHeadDegrees*PIOVER180);
        correctionToCentreEyePosition.rotateAroundY(-yawHeadDegrees*PIOVER180);

        //Add the hydra position (in head tracker reference frame) to the camera offset
        //to get the camera position in head tracker reference frame
        headPos = vecAdd(rel,correctionToCentreEyePosition);

        if (resetOrigin)
        {
          //We compute the "ideal" neck model position, in head tracker reference frame
          Vec3 neckModelToCentreEyePosition = Vec3.createVectorHelper(0, vrSettings.neckBaseToEyeHeight, -vrSettings.eyeProtrusion);
          neckModelToCentreEyePosition.rotateAroundZ(rollHeadDegrees*PIOVER180);
          neckModelToCentreEyePosition.rotateAroundX(pitchHeadDegrees*PIOVER180);
          neckModelToCentreEyePosition.rotateAroundY(-yawHeadDegrees*PIOVER180);

          //The actual hydra position on the head is offset from the eye center by this amount
          Vec3 originOffset = correctionToCentreEyePosition.subtract(neckModelToCentreEyePosition);
       
          //Counteract the base station yaw to get back to absolute razer coordinates
          originOffset.rotateAroundY(-baseStationYawOffset*PIOVER180);

            // save raw - originOffset as origin. That way, when origin is subtracted in the future,
          // positions very close to the current location+orientation will have the eye in the correct spot
          origin = originOffset.subtract(raw);
           
            resetOrigin = false;
        }

        // Rotate the centre eye position around any world yaw offset (mouse/controller induced rotation)
View Full Code Here

Examples of net.minecraft.src.Vec3

    public static Quaternion pow(Quaternion q1, float power)
    {
        Quaternion input = QuaternionHelper.clone(q1);
        float inputMagnitude = QuaternionHelper.magnitude(input);
        Vec3 nHat = Vec3.fakePool.getVecFromPool(input.x, input.y, input.z).normalize();
        Quaternion vectorBit = QuaternionHelper.exp(QuaternionHelper.scalarMultiply(new Quaternion((float)nHat.xCoord, (float)nHat.yCoord, (float)nHat.zCoord, 0), (float)(power * Math.acos(input.w / inputMagnitude))));
        return QuaternionHelper.scalarMultiply(vectorBit, (float)Math.pow(inputMagnitude, power));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.