Package javax.vecmath

Examples of javax.vecmath.Vector3f.normalize()


                Vector3f vec = new Vector3f();
                vec.x = random.nextFloat(-1.0f, 1.0f);
                vec.y = random.nextFloat(-1.0f, 1.0f);
                vec.z = random.nextFloat();

                vec.normalize();
                vec.scale(random.nextFloat(0.0f, 1.0f));
                float scale = i / (float) SSAO_KERNEL_ELEMENTS;
                scale = TeraMath.lerp(0.25f, 1.0f, scale * scale);

                vec.scale(scale);
View Full Code Here


        if (texture == null) {
            ByteBuffer noiseValues = BufferUtils.createByteBuffer(SSAO_NOISE_SIZE * SSAO_NOISE_SIZE * 4);

            for (int i = 0; i < SSAO_NOISE_SIZE * SSAO_NOISE_SIZE; ++i) {
                Vector3f noiseVector = new Vector3f(random.nextFloat(-1.0f, 1.0f), random.nextFloat(-1.0f, 1.0f), 0.0f);
                noiseVector.normalize();

                noiseValues.put((byte) ((noiseVector.x * 0.5 + 0.5) * 255.0f));
                noiseValues.put((byte) ((noiseVector.y * 0.5 + 0.5) * 255.0f));
                noiseValues.put((byte) ((noiseVector.z * 0.5 + 0.5) * 255.0f));
                noiseValues.put((byte) 0x0);
View Full Code Here

        assertEquals(new Percent(25), mockSun.getRiseAngle());
        assertEquals(new Percent(50), mockSun.getZenithAngle());
        Vector3f actualDirection = new Vector3f();
        sunLight.getDirection(actualDirection);
        Vector3f expectedDirection = new Vector3f((float) Math.sqrt(2) / 2, -0.5f, -0.5f);
        expectedDirection.normalize();
        VectorTestHelper.assertVectorEquals(expectedDirection, actualDirection);

        mockSun.setRiseAngle(new Percent(0));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
View Full Code Here

        mockSun.setRiseAngle(new Percent(0));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
        expectedDirection = new Vector3f(1, 0, 0);
        expectedDirection.normalize();
        VectorTestHelper.assertVectorEquals(expectedDirection, actualDirection);

        mockSun.setRiseAngle(new Percent(50));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
View Full Code Here

        mockSun.setRiseAngle(new Percent(50));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
        expectedDirection = new Vector3f(0, -(float) Math.sqrt(2) / 2, -(float) Math.sqrt(2) / 2);
        expectedDirection.normalize();
        VectorTestHelper.assertVectorEquals(expectedDirection, actualDirection);

        mockSun.setRiseAngle(new Percent(75));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
View Full Code Here

        mockSun.setRiseAngle(new Percent(75));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
        expectedDirection = new Vector3f(-(float) Math.sqrt(2) / 2, -0.5f, -0.5f);
        expectedDirection.normalize();
        VectorTestHelper.assertVectorEquals(expectedDirection, actualDirection);

        mockSun.setRiseAngle(new Percent(100));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
View Full Code Here

        mockSun.setRiseAngle(new Percent(100));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
        expectedDirection = new Vector3f(-1, 0, 0);
        expectedDirection.normalize();
        VectorTestHelper.assertVectorEquals(expectedDirection, actualDirection);
    }

    /**
     * Test rise angle with zenith angle set to 0
View Full Code Here

        // Pi/4
        assertEquals(new Percent(25), mockSun.getRiseAngle());
        Vector3f actualDirection = new Vector3f();
        sunLight.getDirection(actualDirection);
        Vector3f expectedDirection = new Vector3f((float) Math.sqrt(2) / 2, 0f, (float) -Math.sqrt(2) / 2);
        expectedDirection.normalize();
        VectorTestHelper.assertVectorEquals(expectedDirection, actualDirection);

        // 0 Pi
        mockSun.setRiseAngle(new Percent(0));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
View Full Code Here

        // 0 Pi
        mockSun.setRiseAngle(new Percent(0));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
        expectedDirection = new Vector3f(1, 0, 0);
        expectedDirection.normalize();
        VectorTestHelper.assertVectorEquals(expectedDirection, actualDirection);

        // Pi/2
        mockSun.setRiseAngle(new Percent(50));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
View Full Code Here

        // Pi/2
        mockSun.setRiseAngle(new Percent(50));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
        sunLight.getDirection(actualDirection);
        expectedDirection = new Vector3f(0, 0, -1);
        expectedDirection.normalize();
        VectorTestHelper.assertVectorEquals(expectedDirection, actualDirection);

        // 3Pi/4
        mockSun.setRiseAngle(new Percent(75));
        sun3D.update(mockSun, SunUpdateCode.riseAngle);
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.