Package javax.vecmath

Examples of javax.vecmath.Vector4f


    public static void addBlockMesh(Tessellator tessellator, Vector4f color, Vector2f[] texOffsets, Vector2f[] texSizes,
                                    float size, float light1, float light2, float posX, float posY, float posZ) {
        final float sizeHalf = size / 2;

        tessellator.resetParams();
        tessellator.setColor(new Vector4f(light1 * color.x, light1 * color.y, light1 * color.z, color.w));

        tessellator.setNormal(new Vector3f(0, 1, 0));
        tessellator.addPoly(
                new Vector3f[]{
                        new Vector3f(-sizeHalf + posX, sizeHalf + posY, sizeHalf + posZ),
                        new Vector3f(sizeHalf + posX, sizeHalf + posY, sizeHalf + posZ),
                        new Vector3f(sizeHalf + posX, sizeHalf + posY, -sizeHalf + posZ),
                        new Vector3f(-sizeHalf + posX, sizeHalf + posY, -sizeHalf + posZ)
                },
                new Vector2f[]{
                        new Vector2f(texOffsets[0].x, texOffsets[0].y),
                        new Vector2f(texOffsets[0].x + texSizes[0].x, texOffsets[0].y),
                        new Vector2f(texOffsets[0].x + texSizes[0].x, texOffsets[0].y + texSizes[0].y),
                        new Vector2f(texOffsets[0].x, texOffsets[0].y + texSizes[0].y)
                });

        tessellator.setNormal(new Vector3f(-1, 0, 0));
        tessellator.addPoly(
                new Vector3f[]{
                        new Vector3f(-sizeHalf + posX, -sizeHalf + posY, -sizeHalf + posZ),
                        new Vector3f(-sizeHalf + posX, -sizeHalf + posY, sizeHalf + posZ),
                        new Vector3f(-sizeHalf + posX, sizeHalf + posY, sizeHalf + posZ),
                        new Vector3f(-sizeHalf + posX, sizeHalf + posY, -sizeHalf + posZ)
                },
                new Vector2f[]{
                        new Vector2f(texOffsets[1].x, texOffsets[1].y + texSizes[1].y),
                        new Vector2f(texOffsets[1].x + texSizes[1].x, texOffsets[1].y + texSizes[1].y),
                        new Vector2f(texOffsets[1].x + texSizes[1].x, texOffsets[1].y),
                        new Vector2f(texOffsets[1].x, texOffsets[1].y)
                });

        tessellator.setNormal(new Vector3f(1, 0, 0));
        tessellator.addPoly(
                new Vector3f[]{
                        new Vector3f(sizeHalf + posX, sizeHalf + posY, -sizeHalf + posZ),
                        new Vector3f(sizeHalf + posX, sizeHalf + posY, sizeHalf + posZ),
                        new Vector3f(sizeHalf + posX, -sizeHalf + posY, sizeHalf + posZ),
                        new Vector3f(sizeHalf + posX, -sizeHalf + posY, -sizeHalf + posZ)
                },
                new Vector2f[]{
                        new Vector2f(texOffsets[2].x, texOffsets[2].y),
                        new Vector2f(texOffsets[2].x + texSizes[2].x, texOffsets[2].y),
                        new Vector2f(texOffsets[2].x + texSizes[2].x, texOffsets[2].y + texSizes[2].y),
                        new Vector2f(texOffsets[2].x, texOffsets[2].y + texSizes[2].y)
                });


        tessellator.setColor(new Vector4f(light2 * color.x, light2 * color.y, light2 * color.z, color.w));

        tessellator.setNormal(new Vector3f(0, 0, -1));
        tessellator.addPoly(
                new Vector3f[]{
                        new Vector3f(-sizeHalf + posX, sizeHalf + posY, -sizeHalf + posZ),
View Full Code Here


                });
    }

    public static void addGUIQuadMesh(Tessellator tessellator, Vector4f color, float sizeX, float sizeY) {
        tessellator.resetParams();
        tessellator.setColor(new Vector4f(color.x, color.y, color.z, color.w));
        tessellator.setUseLighting(false);
        tessellator.setUseNormals(false);

        tessellator.addPoly(
                new Vector3f[]{
View Full Code Here

                int g = buffer.get((posY + y) * stride + (posX + x) * 4 + 1) & 255;
                int b = buffer.get((posY + y) * stride + (posX + x) * 4 + 2) & 255;
                int a = buffer.get((posY + y) * stride + (posX + x) * 4 + 3) & 255;

                if (a > alphaLimit) {
                    Vector4f color = new Vector4f(r / 255f, g / 255f, b / 255f, a / 255f);
                    TessellatorHelper.addBlockMesh(tessellator, color, 2f / textureSize, 1.0f, 0.5f, 2f / textureSize * x - 0.5f, 2f / textureSize * (15 - y) - 1f, 0f);

                    if (withContour) {
                        int newX = 0;
                        int newY = 0;
                        int newA = 0;

                        for (int i = 0; i < 4; i++) {
                            newA = alphaLimit + 1;
                            switch (i) {
                                case 0:
                                    //check left
                                    if (x > 0) {
                                        newX = x - 1;
                                        newY = y;
                                        newA = buffer.get((posY + newY) * stride + (posX + newX) * 4 + 3) & 255;
                                    }
                                    break;
                                case 1:
                                    //check top
                                    if (y > 0) {
                                        newX = x;
                                        newY = y - 1;
                                        newA = buffer.get((posY + newY) * stride + (posX + newX) * 4 + 3) & 255;
                                    }
                                    break;
                                case 2:
                                    //check right
                                    if (x < 16) {
                                        newX = x + 1;
                                        newY = y;
                                        newA = buffer.get((posY + newY) * stride + (posX + newX) * 4 + 3) & 255;
                                    }
                                    break;
                                case 3:
                                    //check bottom
                                    if (y < 16) {
                                        newX = x;
                                        newY = y + 1;
                                        newA = buffer.get((posY + newY) * stride + (posX + newX) * 4 + 3) & 255;
                                    }
                                    break;
                                default:
                                    break;
                            }

                            if (newA < alphaLimit) {
                                Vector4f cColor = new Vector4f(colorContour.x / 255f, colorContour.y / 255f, colorContour.z / 255f, colorContour.w);
                                TessellatorHelper.addBlockMesh(tessellator, cColor, 0.125f, 1.0f, 0.5f, 2f * 0.0625f * newX - 0.5f, 0.125f * (15 - newY) - 1f, 0f);
                            }
                        }
                    }
                }
View Full Code Here

    public Vector4f deserialize(PersistedData data, DeserializationContext context) {
        if (data.isArray()) {
            PersistedDataArray dataArray = data.getAsArray();
            if (dataArray.isNumberArray() && dataArray.size() > 3) {
                TFloatList floats = dataArray.getAsFloatArray();
                return new Vector4f(floats.get(0), floats.get(1), floats.get(2), floats.get(3));
            }
        }
        return null;
    }
View Full Code Here

     * Init. a new block with default properties in place.
     */
    public Block() {
        for (BlockPart part : BlockPart.values()) {
            colorSource.put(part, DefaultColorSource.DEFAULT);
            colorOffsets.put(part, new Vector4f(1.0f, 1.0f, 1.0f, 1.0f));
        }
    }
View Full Code Here

     * @param biome The block's biome
     * @return The color offset
     */
    public Vector4f calcColorOffsetFor(BlockPart part, Biome biome) {
        BlockColorSource source = getColorSource(part);
        Vector4f color = source.calcColor(biome);

        Vector4f colorOffset = colorOffsets.get(part);
        color.x *= colorOffset.x;
        color.y *= colorOffset.y;
        color.z *= colorOffset.z;
        color.w *= colorOffset.w;

View Full Code Here

        if (worldRenderer != null) {
            Vector3f sunDirection = worldRenderer.getSkysphere().getSunDirection(true);

            Camera activeCamera = CoreRegistry.get(WorldRenderer.class).getActiveCamera();

            Vector4f sunPositionWorldSpace4 = new Vector4f(sunDirection.x * 10000.0f, sunDirection.y * 10000.0f, sunDirection.z * 10000.0f, 1.0f);
            Vector4f sunPositionScreenSpace = new Vector4f();
            activeCamera.getViewProjectionMatrix().transform(sunPositionWorldSpace4, sunPositionScreenSpace);

            sunPositionScreenSpace.x /= sunPositionScreenSpace.w;
            sunPositionScreenSpace.y /= sunPositionScreenSpace.w;
            sunPositionScreenSpace.z /= sunPositionScreenSpace.w;
View Full Code Here

    @EditorRange(min = 0.0f, max = 10.0f)
    private float skyNightBrightness = 1.0f;

    public static Vector3d getAllWeatherZenith(float thetaSunAngle, float turbidity) {
        float thetaSun = (float) Math.acos(thetaSunAngle);
        Vector4f cx1 = new Vector4f(0.0f, 0.00209f, -0.00375f, 0.00165f);
        Vector4f cx2 = new Vector4f(0.00394f, -0.03202f, 0.06377f, -0.02903f);
        Vector4f cx3 = new Vector4f(0.25886f, 0.06052f, -0.21196f, 0.11693f);
        Vector4f cy1 = new Vector4f(0.0f, 0.00317f, -0.00610f, 0.00275f);
        Vector4f cy2 = new Vector4f(0.00516f, -0.04153f, 0.08970f, -0.04214f);
        Vector4f cy3 = new Vector4f(0.26688f, 0.06670f, -0.26756f, 0.15346f);

        float t2 = turbidity * turbidity;
        float chi = (4.0f / 9.0f - turbidity / 120.0f) * ((float) Math.PI - 2.0f * thetaSun);

        Vector4f theta = new Vector4f(1, thetaSun, thetaSun * thetaSun, thetaSun * thetaSun * thetaSun);

        float why = (4.0453f * turbidity - 4.9710f) * (float) Math.tan(chi) - 0.2155f * turbidity + 2.4192f;
        float x = t2 * cx1.dot(theta) + turbidity * cx2.dot(theta) + cx3.dot(theta);
        float y = t2 * cy1.dot(theta) + turbidity * cy2.dot(theta) + cy3.dot(theta);

View Full Code Here

    public int rgba() {
        return representation;
    }

    public Vector4f toVector4f() {
        return new Vector4f(rf(), gf(), bf(), af());
    }
View Full Code Here

        ((NUIManagerInternal) nuiManager).refreshWidgetsLibrary();

        // TODO: This should be elsewhere
        // Create gelatinousCubeMesh
        Tessellator tessellator = new Tessellator();
        TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1.0f, 1.0f, 1.0f, 1.0f), 0.8f, 0.8f, 0.6f, 0f, 0f, 0f);
        TessellatorHelper.addBlockMesh(tessellator, new Vector4f(1.0f, 1.0f, 1.0f, 0.6f), 1.0f, 1.0f, 0.8f, 0f, 0f, 0f);
        tessellator.generateMesh(new AssetUri(AssetType.MESH, TerasologyConstants.ENGINE_MODULE, "gelatinousCube"));
        return true;
    }
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector4f

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.