Java Code Examples for org.lwjgl.util.vector.Vector4f#dot()

The following examples show how to use org.lwjgl.util.vector.Vector4f#dot() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GData5.java    From ldparteditor with MIT License 6 votes vote down vote up
public void isShown(Matrix4f viewport, ThreadsafeHashMap<GData1, Matrix4f> CACHE_viewByProjection, float zoom) {

        if (wasShown) {
            return;
        }

        final Matrix4f M2 = CACHE_viewByProjection.get(parent);
        if (M2 == null) {
            Matrix4f.mul(viewport, parent.productMatrix, M);
            CACHE_viewByProjection.put(parent, M);
        } else {
            M = M2;
        }

        // Calculate the real coordinates
        Matrix4f.transform(M, A2, A);
        Matrix4f.transform(M, B2, B);
        Matrix4f.transform(M, C2, C);
        Matrix4f.transform(M, D2, D);

        N.x = A.y - B.y;
        N.y = B.x - A.x;
        N.z = 0f;
        N.w = 1f;
        wasShown = zoom / Vector4f.dot(N, Vector4f.sub(C, A, null)) * Vector4f.dot(N, Vector4f.sub(D, A, null)) > -1e-20f;
    }
 
Example 2
Source File: GData5.java    From ldparteditor with MIT License 4 votes vote down vote up
@Override
public void drawGL20_BFC_Textured(Composite3D c3d) {
    // done :)
    if (GData.globalDrawObjects) {
        final OpenGLRenderer20 r = (OpenGLRenderer20) c3d.getRenderer();
        GL20.glUniform1f(r.getNormalSwitchLoc(), GData.globalNegativeDeterminant ^ GData.globalInvertNext ? 1f : 0f);
        GL20.glUniform1f(r.getNoTextureSwitch(), 1f);
        GL20.glUniform1f(r.getNoLightSwitch(), 1f);
        GL20.glUniform1f(r.getCubeMapSwitch(), 0f);

        if (!visible)
            return;
        if (!c3d.isDrawingSolidMaterials())
            return;

        float result;
        float zoom = c3d.getZoom();
        switch (c3d.getLineMode()) {
        case 1:
            result = 1f;
            break;
        case 2:
        case 4:
            return;
        default:
            final Matrix4f M2 = GData.CACHE_viewByProjection.get(parent);
            if (M2 == null) {
                Matrix4f.mul(c3d.getViewport(), parent.productMatrix, M);
                GData.CACHE_viewByProjection.put(parent, M);
            } else {
                M = M2;
            }
            // Calculate the real coordinates
            Matrix4f.transform(M, A2, A);
            Matrix4f.transform(M, B2, B);
            Matrix4f.transform(M, C2, C);
            Matrix4f.transform(M, D2, D);

            N.x = A.y - B.y;
            N.y = B.x - A.x;

            result = zoom / Vector4f.dot(N, Vector4f.sub(C, A, null)) * Vector4f.dot(N, Vector4f.sub(D, A, null));
            break;
        }

        if (result > -1e-20f) {

            float r2;
            float g2;
            float b2;
            int cn;
            if (colourNumber == 24 && (cn = parent.r == .5f && parent.g == .5f && parent.b == .5f && (parent.a == 1.1f || parent.a == -1)  ? 16 : View.getLDConfigIndex(parent.r,  parent.g,  parent.b)) != 16) {
                GColour c = View.getLDConfigEdgeColour(cn, c3d);
                r2 = c.getR();
                g2 = c.getG();
                b2 = c.getB();
            } else {
                r2 = this.r;
                g2 = this.g;
                b2 = this.b;
            }

            GL11.glLineWidth(View.lineWidthGL[0]);
            GL11.glColor4f(r2, g2, b2, 1f);
            GL11.glBegin(GL11.GL_LINES);
            GraphicalDataTools.setVertex(x1, y1, z1, this, true);
            GraphicalDataTools.setVertex(x2, y2, z2, this, true);
            GL11.glEnd();
        }
    }
    if (GData.globalFoundTEXMAPNEXT) {
        GData.globalFoundTEXMAPStack.pop();
        GData.globalTextureStack.pop();
        GData.globalFoundTEXMAPStack.push(false);
        GData.globalFoundTEXMAPNEXT = false;
    }
}