Java Code Examples for org.lwjgl.opengl.GL11#glMultMatrixf()

The following examples show how to use org.lwjgl.opengl.GL11#glMultMatrixf() . 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: PGData1.java    From ldparteditor with MIT License 5 votes vote down vote up
@Override
public void drawBFCprimitive_GL20(int drawOnlyMode) {
    if (matrix != null) {
        byte tempWinding = PGData.localWinding;
        boolean tempInvertNext = PGData.globalInvertNext;
        boolean tempInvertNextFound = PGData.globalInvertNextFound;
        boolean tempNegativeDeterminant = PGData.globalNegativeDeterminant;
        PGData.globalInvertNextFound = false;
        PGData.localWinding = BFC.NOCERTIFY;
        PGData.globalNegativeDeterminant = PGData.globalNegativeDeterminant ^ negativeDeterminant;
        GL11.glPushMatrix();
        GL11.glMultMatrixf(matrix);
        PGData data2draw = myGData;
        if (PGData.accumClip > 0) {
            PGData.accumClip++;
            while ((data2draw = data2draw.getNext()) != null && !ViewIdleManager.pause[0].get())
                data2draw.drawBFCprimitive_GL20(drawOnlyMode);
            PGData.accumClip--;
        } else {
            while ((data2draw = data2draw.getNext()) != null && !ViewIdleManager.pause[0].get()) {
                data2draw.drawBFCprimitive_GL20(drawOnlyMode);
            }
            if (PGData.accumClip > 0)
                PGData.accumClip = 0;
        }
        GL11.glPopMatrix();
        PGData.localWinding = tempWinding;
        if (tempInvertNextFound)
            PGData.globalInvertNext = !tempInvertNext;
        PGData.globalNegativeDeterminant = tempNegativeDeterminant;
    }
}
 
Example 2
Source File: LWJGL15DrawContext.java    From settlers-remake with MIT License 5 votes vote down vote up
public void drawTrianglesWithTextureColored(TextureHandle textureid, GeometryHandle shapeHandle, GeometryHandle colorHandle, int offset, int lines, int width, int stride, float x, float y) {
	bindTexture(textureid);
	int starti = offset < 0 ? (int)Math.ceil(-offset/(float)stride) : 0;

	if(lsz != -1) GL11.glPopMatrix();
	GL11.glPushMatrix();
	GL11.glTranslatef(x, y, -.1f);
	GL11.glScalef(1, 1, 0);
	GL11.glMultMatrixf(heightMatrix);

	if(!tex_coord_on) {
		GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
		tex_coord_on = true;
	}

	bindGeometry(shapeHandle);
	GL11.glVertexPointer(3, GL11.GL_FLOAT, 5 * 4, 0);
	GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 5 * 4, 3 * 4);

	bindGeometry(colorHandle);
	GL11.glColorPointer(4, GL11.GL_UNSIGNED_BYTE, 0, 0);

	GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
	for (int i = starti; i != lines; i++) {
		GL11.glDrawArrays(GL11.GL_TRIANGLES, (offset + stride * i) * 3, width * 3);
	}
	GL11.glDisableClientState(GL11.GL_COLOR_ARRAY);

	GL11.glPopMatrix();
	lsz = -1;
}
 
Example 3
Source File: Circle.java    From ldparteditor with MIT License 4 votes vote down vote up
public void draw(float x, float y, float z, float zoom) {
    final float zoom_inv = 1f / zoom;
    GL11.glPushMatrix();

    GL11.glTranslatef(x, y, z);
    GL11.glMultMatrixf(matrix);
    GL11.glScalef(zoom_inv, zoom_inv, zoom_inv);

    GL11.glColor3f(r, g, b);
    GL11.glBegin(GL11.GL_QUAD_STRIP);

    GL11.glVertex3f(circle[0], 0f, circle[1]);
    GL11.glVertex3f(circle2[0], 0f, circle2[1]);
    GL11.glVertex3f(circle[2], 0f, circle[3]);
    GL11.glVertex3f(circle2[2], 0f, circle2[3]);
    GL11.glVertex3f(circle[4], 0f, circle[5]);
    GL11.glVertex3f(circle2[4], 0f, circle2[5]);
    GL11.glVertex3f(circle[6], 0f, circle[7]);
    GL11.glVertex3f(circle2[6], 0f, circle2[7]);

    GL11.glVertex3f(circle[8], 0f, circle[9]);
    GL11.glVertex3f(circle2[8], 0f, circle2[9]);
    GL11.glVertex3f(circle[10], 0f, circle[11]);
    GL11.glVertex3f(circle2[10], 0f, circle2[11]);
    GL11.glVertex3f(circle[12], 0f, circle[13]);
    GL11.glVertex3f(circle2[12], 0f, circle2[13]);
    GL11.glVertex3f(circle[14], 0f, circle[15]);
    GL11.glVertex3f(circle2[14], 0f, circle2[15]);

    GL11.glVertex3f(circle[16], 0f, circle[17]);
    GL11.glVertex3f(circle2[16], 0f, circle2[17]);
    GL11.glVertex3f(circle[18], 0f, circle[19]);
    GL11.glVertex3f(circle2[18], 0f, circle2[19]);
    GL11.glVertex3f(circle[20], 0f, circle[21]);
    GL11.glVertex3f(circle2[20], 0f, circle2[21]);
    GL11.glVertex3f(circle[22], 0f, circle[23]);
    GL11.glVertex3f(circle2[22], 0f, circle2[23]);

    GL11.glVertex3f(circle[24], 0f, circle[25]);
    GL11.glVertex3f(circle2[24], 0f, circle2[25]);
    GL11.glVertex3f(circle[26], 0f, circle[27]);
    GL11.glVertex3f(circle2[26], 0f, circle2[27]);
    GL11.glVertex3f(circle[28], 0f, circle[29]);
    GL11.glVertex3f(circle2[28], 0f, circle2[29]);
    GL11.glVertex3f(circle[30], 0f, circle[31]);
    GL11.glVertex3f(circle2[30], 0f, circle2[31]);

    GL11.glVertex3f(circle[32], 0f, circle[33]);
    GL11.glVertex3f(circle2[32], 0f, circle2[33]);
    GL11.glVertex3f(circle[34], 0f, circle[35]);
    GL11.glVertex3f(circle2[34], 0f, circle2[35]);
    GL11.glVertex3f(circle[36], 0f, circle[37]);
    GL11.glVertex3f(circle2[36], 0f, circle2[37]);
    GL11.glVertex3f(circle[38], 0f, circle[39]);
    GL11.glVertex3f(circle2[38], 0f, circle2[39]);

    GL11.glVertex3f(circle[40], 0f, circle[41]);
    GL11.glVertex3f(circle2[40], 0f, circle2[41]);
    GL11.glVertex3f(circle[42], 0f, circle[43]);
    GL11.glVertex3f(circle2[42], 0f, circle2[43]);
    GL11.glVertex3f(circle[44], 0f, circle[45]);
    GL11.glVertex3f(circle2[44], 0f, circle2[45]);
    GL11.glVertex3f(circle[46], 0f, circle[47]);
    GL11.glVertex3f(circle2[46], 0f, circle2[47]);

    GL11.glVertex3f(circle[48], 0f, circle[49]);
    GL11.glVertex3f(circle2[48], 0f, circle2[49]);
    GL11.glVertex3f(circle[50], 0f, circle[51]);
    GL11.glVertex3f(circle2[50], 0f, circle2[51]);
    GL11.glVertex3f(circle[52], 0f, circle[53]);
    GL11.glVertex3f(circle2[52], 0f, circle2[53]);
    GL11.glVertex3f(circle[54], 0f, circle[55]);
    GL11.glVertex3f(circle2[54], 0f, circle2[55]);

    GL11.glVertex3f(circle[56], 0f, circle[57]);
    GL11.glVertex3f(circle2[56], 0f, circle2[57]);
    GL11.glVertex3f(circle[58], 0f, circle[59]);
    GL11.glVertex3f(circle2[58], 0f, circle2[59]);
    GL11.glVertex3f(circle[60], 0f, circle[61]);
    GL11.glVertex3f(circle2[60], 0f, circle2[61]);
    GL11.glVertex3f(circle[62], 0f, circle[63]);
    GL11.glVertex3f(circle2[62], 0f, circle2[63]);

    GL11.glVertex3f(circle[64], 0f, circle[65]);
    GL11.glVertex3f(circle2[64], 0f, circle2[65]);
    GL11.glEnd();

    GL11.glPopMatrix();
}
 
Example 4
Source File: Arrow.java    From ldparteditor with MIT License 4 votes vote down vote up
public void drawGL20(float x, float y, float z, float zoom) {
    final float zoom_inv = 1f / zoom;
    GL11.glPushMatrix();

    GL11.glTranslatef(x, y, z);
    GL11.glMultMatrixf(matrix_buf);
    GL11.glScalef(zoom_inv, zoom_inv, zoom_inv);

    GL11.glLineWidth(line_width);
    GL11.glColor3f(r, g, b);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(0f, 0f, 0f);
    GL11.glVertex3f(0f, line_end, 0f);
    GL11.glEnd();

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex3f(0f, length, 0f);

    GL11.glVertex3f(cone[0], cone_start, cone[1]);
    GL11.glVertex3f(cone[2], cone_start, cone[3]);
    GL11.glVertex3f(cone[4], cone_start, cone[5]);
    GL11.glVertex3f(cone[6], cone_start, cone[7]);

    GL11.glVertex3f(cone[8], cone_start, cone[9]);
    GL11.glVertex3f(cone[10], cone_start, cone[11]);
    GL11.glVertex3f(cone[12], cone_start, cone[13]);
    GL11.glVertex3f(cone[14], cone_start, cone[15]);

    GL11.glVertex3f(cone[16], cone_start, cone[17]);
    GL11.glVertex3f(cone[18], cone_start, cone[19]);
    GL11.glVertex3f(cone[20], cone_start, cone[21]);
    GL11.glVertex3f(cone[22], cone_start, cone[23]);

    GL11.glVertex3f(cone[24], cone_start, cone[25]);
    GL11.glVertex3f(cone[26], cone_start, cone[27]);
    GL11.glVertex3f(cone[28], cone_start, cone[29]);
    GL11.glVertex3f(cone[30], cone_start, cone[31]);

    GL11.glVertex3f(cone[32], cone_start, cone[33]);

    GL11.glEnd();

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glVertex3f(0f, cone_start, 0f);

    GL11.glVertex3f(cone[32], cone_start, cone[33]);

    GL11.glVertex3f(cone[30], cone_start, cone[31]);
    GL11.glVertex3f(cone[28], cone_start, cone[29]);
    GL11.glVertex3f(cone[26], cone_start, cone[27]);
    GL11.glVertex3f(cone[24], cone_start, cone[25]);

    GL11.glVertex3f(cone[22], cone_start, cone[23]);
    GL11.glVertex3f(cone[20], cone_start, cone[21]);
    GL11.glVertex3f(cone[18], cone_start, cone[19]);
    GL11.glVertex3f(cone[16], cone_start, cone[17]);

    GL11.glVertex3f(cone[14], cone_start, cone[15]);
    GL11.glVertex3f(cone[12], cone_start, cone[13]);
    GL11.glVertex3f(cone[10], cone_start, cone[11]);
    GL11.glVertex3f(cone[8], cone_start, cone[9]);

    GL11.glVertex3f(cone[6], cone_start, cone[7]);
    GL11.glVertex3f(cone[4], cone_start, cone[5]);
    GL11.glVertex3f(cone[2], cone_start, cone[3]);
    GL11.glVertex3f(cone[0], cone_start, cone[1]);

    GL11.glEnd();

    GL11.glPopMatrix();
}
 
Example 5
Source File: ArrowBlunt.java    From ldparteditor with MIT License 4 votes vote down vote up
public void draw(float x, float y, float z, float zoom) {
    final float zoom_inv = 1f / zoom;
    GL11.glPushMatrix();

    GL11.glTranslatef(x, y, z);
    GL11.glMultMatrixf(matrix);
    GL11.glScalef(zoom_inv, zoom_inv, zoom_inv);

    GL11.glLineWidth(line_width);
    GL11.glColor3f(r, g, b);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(0f, 0f, 0f);
    GL11.glVertex3f(0f, line_end, 0f);
    GL11.glEnd();

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex3f(cube_x[3], cube_y[3], cube_z[3]);
    GL11.glVertex3f(cube_x[2], cube_y[2], cube_z[2]);
    GL11.glVertex3f(cube_x[1], cube_y[1], cube_z[1]);
    GL11.glVertex3f(cube_x[0], cube_y[0], cube_z[0]);

    GL11.glVertex3f(cube_x[4], cube_y[4], cube_z[4]);
    GL11.glVertex3f(cube_x[5], cube_y[5], cube_z[5]);
    GL11.glVertex3f(cube_x[6], cube_y[6], cube_z[6]);
    GL11.glVertex3f(cube_x[7], cube_y[7], cube_z[7]);

    GL11.glEnd();

    GL11.glBegin(GL11.GL_QUAD_STRIP);
    GL11.glVertex3f(cube_x[0], cube_y[0], cube_z[0]);
    GL11.glVertex3f(cube_x[4], cube_y[4], cube_z[4]);
    GL11.glVertex3f(cube_x[3], cube_y[3], cube_z[3]);
    GL11.glVertex3f(cube_x[7], cube_y[7], cube_z[7]);
    GL11.glVertex3f(cube_x[2], cube_y[2], cube_z[2]);
    GL11.glVertex3f(cube_x[6], cube_y[6], cube_z[6]);
    GL11.glVertex3f(cube_x[1], cube_y[1], cube_z[1]);
    GL11.glVertex3f(cube_x[5], cube_y[5], cube_z[5]);
    GL11.glVertex3f(cube_x[0], cube_y[0], cube_z[0]);
    GL11.glVertex3f(cube_x[4], cube_y[4], cube_z[4]);
    GL11.glEnd();

    GL11.glPopMatrix();
}
 
Example 6
Source File: GData3.java    From ldparteditor with MIT License 4 votes vote down vote up
public void drawProtractor_GL20(boolean selected, Composite3D c3d, BigDecimal x1c, BigDecimal y1c, BigDecimal z1c, BigDecimal x2c, BigDecimal y2c, BigDecimal z2c, BigDecimal x3c, BigDecimal y3c, BigDecimal z3c) {
    final java.text.DecimalFormat NUMBER_FORMAT2F = new java.text.DecimalFormat(View.NUMBER_FORMAT2F, new DecimalFormatSymbols(MyLanguage.LOCALE));
    final OpenGLRenderer20 renderer = (OpenGLRenderer20) c3d.getRenderer();
    final float zoom = 1f / c3d.getZoom();

    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glLineWidth(View.lineWidthGL[0]);
    if (selected) {
        GL11.glColor4f(View.vertex_selected_Colour_r[0], View.vertex_selected_Colour_g[0], View.vertex_selected_Colour_b[0], 1f);
        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex3f(x1, y1, z1);
        GL11.glVertex3f(x2, y2, z2);
        GL11.glEnd();
    } else {
        final float s = ((r + g + b) / 3 + .5f) % 1f;
        GL11.glColor4f(s, s, s, 1f);
        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex3f(x1, y1, z1);
        GL11.glVertex3f(x2, y2, z2);
        GL11.glEnd();
    }
    GL11.glColor4f(r, g, b, 1f);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(x1, y1, z1);
    GL11.glVertex3f(x3, y3, z3);
    GL11.glEnd();

    final Vector4f textOrigin = new Vector4f(x1, y1, z1, 1f);
    Matrix4f.transform(c3d.getRotation(), textOrigin, textOrigin);

    Vector3d va = new Vector3d(x1c, y1c, z1c);
    Vector3d vb = new Vector3d(x2c, y2c, z2c);
    Vector3d vc = new Vector3d(x3c, y3c, z3c);
    vb = Vector3d.sub(va, vb);
    vc = Vector3d.sub(va, vc);
    double angle = Vector3d.angle(vb, vc);
    BigDecimal ang = new BigDecimal(angle);
    String angle_s = NUMBER_FORMAT2F.format(ang) + "°"; //$NON-NLS-1$

    float sx1 = x1 + (x2 - x1) * .2f;
    float sy1 = y1 + (y2 - y1) * .2f;
    float sz1 = z1 + (z2 - z1) * .2f;
    float sx2 = x1 + (x3 - x1) * .2f;
    float sy2 = y1 + (y3 - y1) * .2f;
    float sz2 = z1 + (z3 - z1) * .2f;
    float sx1t = x1 + (x2 - x1) * .25f;
    float sy1t = y1 + (y2 - y1) * .25f;
    float sz1t = z1 + (z2 - z1) * .25f;
    float sx2t = x1 + (x3 - x1) * .25f;
    float sy2t = y1 + (y3 - y1) * .25f;
    float sz2t = z1 + (z3 - z1) * .25f;
    float sx1tt = x1 + (x2 - x1) * .24f;
    float sy1tt = y1 + (y2 - y1) * .24f;
    float sz1tt = z1 + (z2 - z1) * .24f;
    float sx2tt = x1 + (x3 - x1) * .24f;
    float sy2tt = y1 + (y3 - y1) * .24f;
    float sz2tt = z1 + (z3 - z1) * .24f;
    float sx3 = sx1t * .5f + sx2t * .5f;
    float sy3 = sy1t * .5f + sy2t * .5f;
    float sz3 = sz1t * .5f + sz2t * .5f;
    float sx3r = sx1tt * .7f + sx2tt * .3f;
    float sy3r = sy1tt * .7f + sy2tt * .3f;
    float sz3r = sz1tt * .7f + sz2tt * .3f;
    float sx3l = sx1tt * .3f + sx2tt * .7f;
    float sy3l = sy1tt * .3f + sy2tt * .7f;
    float sz3l = sz1tt * .3f + sz2tt * .7f;

    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(sx1, sy1, sz1);
    GL11.glVertex3f(sx3r, sy3r, sz3r);
    GL11.glVertex3f(sx3r, sy3r, sz3r);
    GL11.glVertex3f(sx3, sy3, sz3);
    GL11.glVertex3f(sx3, sy3, sz3);
    GL11.glVertex3f(sx3l, sy3l, sz3l);
    GL11.glVertex3f(sx3l, sy3l, sz3l);
    GL11.glVertex3f(sx2, sy2, sz2);
    GL11.glEnd();

    GL11.glPushMatrix();
    GL11.glMultMatrixf(renderer.getRotationInverse());

    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    PGData3.beginDrawText();
    GL11.glColor4f(r, g, b, 1f);
    drawNumber(angle_s, textOrigin.x, textOrigin.y, textOrigin.z, zoom);
    PGData3.endDrawText();
    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_LIGHTING);
}
 
Example 7
Source File: GData1.java    From ldparteditor with MIT License 4 votes vote down vote up
@Override
public void drawGL20(Composite3D c3d) {
    if (!visible)
        return;
    if (matrix != null) {

        final Rectangle bounds = c3d.getClientArea();
        final PerspectiveCalculator PC = c3d.getPerspectiveCalculator();

        Vector4f bbmin = new Vector4f();
        Vector4f bbmax = new Vector4f();

        Vector4f c1 = new Vector4f(boundingBoxMin);
        Vector4f c2 = new Vector4f(boundingBoxMin);
        Vector4f c3 = new Vector4f(boundingBoxMin);
        Vector4f c4 = new Vector4f(boundingBoxMin);
        Vector4f c5 = new Vector4f(boundingBoxMax);
        Vector4f c6 = new Vector4f(boundingBoxMax);
        Vector4f c7 = new Vector4f(boundingBoxMax);
        Vector4f c8 = new Vector4f(boundingBoxMax);

        c2.x = boundingBoxMax.x;
        c3.y = boundingBoxMax.y;
        c4.z = boundingBoxMax.z;

        c6.x = boundingBoxMin.x;
        c7.y = boundingBoxMin.y;
        c8.z = boundingBoxMin.z;

        c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z));
        c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z));
        c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z));
        c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z));
        c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z));
        c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z));
        c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z));
        c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z));

        bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x)))))));
        bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x)))))));

        bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y)))))));
        bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y)))))));

        Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y));

        boolean tempNegativeDeterminant = GData.globalNegativeDeterminant;
        GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant;

        if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0)
                || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height)
                || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) {

            GL11.glPushMatrix();
            GL11.glMultMatrixf(matrix);

            if (c3d.isShowingLogo()) {
                if (filesWithLogo1.contains(shortName))
                    drawStudLogo1_GL20();
                else if (filesWithLogo2.contains(shortName))
                    drawStudLogo2_GL20();
            }

            GData data2draw = myGData;
            if (GData.accumClip > 0) {
                GData.accumClip++;
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20(c3d);
                GData.accumClip--;
            } else {
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20(c3d);
                if (GData.accumClip > 0)
                    GData.accumClip = 0;
            }

            GL11.glPopMatrix();

        }

        GData.globalNegativeDeterminant = tempNegativeDeterminant;

    }
}
 
Example 8
Source File: GData1.java    From ldparteditor with MIT License 4 votes vote down vote up
@Override
public void drawGL20_RandomColours(Composite3D c3d) {
    if (!visible)
        return;
    if (matrix != null) {

        final Rectangle bounds = c3d.getClientArea();
        final PerspectiveCalculator PC = c3d.getPerspectiveCalculator();

        Vector4f bbmin = new Vector4f();
        Vector4f bbmax = new Vector4f();

        Vector4f c1 = new Vector4f(boundingBoxMin);
        Vector4f c2 = new Vector4f(boundingBoxMin);
        Vector4f c3 = new Vector4f(boundingBoxMin);
        Vector4f c4 = new Vector4f(boundingBoxMin);
        Vector4f c5 = new Vector4f(boundingBoxMax);
        Vector4f c6 = new Vector4f(boundingBoxMax);
        Vector4f c7 = new Vector4f(boundingBoxMax);
        Vector4f c8 = new Vector4f(boundingBoxMax);

        c2.x = boundingBoxMax.x;
        c3.y = boundingBoxMax.y;
        c4.z = boundingBoxMax.z;

        c6.x = boundingBoxMin.x;
        c7.y = boundingBoxMin.y;
        c8.z = boundingBoxMin.z;

        c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z));
        c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z));
        c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z));
        c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z));
        c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z));
        c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z));
        c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z));
        c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z));

        bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x)))))));
        bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x)))))));

        bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y)))))));
        bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y)))))));

        Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y));

        boolean tempNegativeDeterminant = GData.globalNegativeDeterminant;
        GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant;

        if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0)
                || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height)
                || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) {

            GL11.glPushMatrix();
            GL11.glMultMatrixf(matrix);

            if (c3d.isShowingLogo()) {
                if (filesWithLogo1.contains(shortName))
                    drawStudLogo1_GL20();
                else if (filesWithLogo2.contains(shortName))
                    drawStudLogo2_GL20();
            }

            GData data2draw = myGData;
            if (GData.accumClip > 0) {
                GData.accumClip++;
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20_RandomColours(c3d);
                GData.accumClip--;
            } else {
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20_RandomColours(c3d);
                if (GData.accumClip > 0)
                    GData.accumClip = 0;
            }

            GL11.glPopMatrix();

        }

        GData.globalNegativeDeterminant = tempNegativeDeterminant;

    }
}
 
Example 9
Source File: GData1.java    From ldparteditor with MIT License 4 votes vote down vote up
@Override
public void drawGL20_BFCuncertified(Composite3D c3d) {
    if (!visible)
        return;
    if (matrix != null) {

        final Rectangle bounds = c3d.getClientArea();
        final PerspectiveCalculator PC = c3d.getPerspectiveCalculator();

        Vector4f bbmin = new Vector4f();
        Vector4f bbmax = new Vector4f();

        Vector4f c1 = new Vector4f(boundingBoxMin);
        Vector4f c2 = new Vector4f(boundingBoxMin);
        Vector4f c3 = new Vector4f(boundingBoxMin);
        Vector4f c4 = new Vector4f(boundingBoxMin);
        Vector4f c5 = new Vector4f(boundingBoxMax);
        Vector4f c6 = new Vector4f(boundingBoxMax);
        Vector4f c7 = new Vector4f(boundingBoxMax);
        Vector4f c8 = new Vector4f(boundingBoxMax);

        c2.x = boundingBoxMax.x;
        c3.y = boundingBoxMax.y;
        c4.z = boundingBoxMax.z;

        c6.x = boundingBoxMin.x;
        c7.y = boundingBoxMin.y;
        c8.z = boundingBoxMin.z;

        c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z));
        c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z));
        c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z));
        c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z));
        c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z));
        c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z));
        c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z));
        c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z));

        bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x)))))));
        bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x)))))));

        bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y)))))));
        bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y)))))));

        Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y));


        byte tempWinding = GData.localWinding;
        boolean tempInvertNext = GData.globalInvertNext;
        boolean tempInvertNextFound = GData.globalInvertNextFound;
        boolean tempNegativeDeterminant = GData.globalNegativeDeterminant;
        GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant;

        if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0)
                || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height)
                || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) {

            GL11.glPushMatrix();
            GL11.glMultMatrixf(matrix);

            if (c3d.isShowingLogo()) {
                if (filesWithLogo1.contains(shortName))
                    drawStudLogo1_GL20();
                else if (filesWithLogo2.contains(shortName))
                    drawStudLogo2_GL20();
            }

            GData data2draw = myGData;
            if (GData.accumClip > 0) {
                GData.accumClip++;
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20_BFCuncertified(c3d);
                GData.accumClip--;
            } else {
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20_BFCuncertified(c3d);
                if (GData.accumClip > 0)
                    GData.accumClip = 0;
            }

            GL11.glPopMatrix();

        }

        GData.localWinding = tempWinding;
        if (tempInvertNextFound)
            GData.globalInvertNext = !tempInvertNext;

        GData.globalNegativeDeterminant = tempNegativeDeterminant;

    }
}
 
Example 10
Source File: GData1.java    From ldparteditor with MIT License 4 votes vote down vote up
@Override
public void drawGL20_CoplanarityHeatmap(Composite3D c3d) {
    if (!visible)
        return;
    if (matrix != null) {

        final Rectangle bounds = c3d.getClientArea();
        final PerspectiveCalculator PC = c3d.getPerspectiveCalculator();

        Vector4f bbmin = new Vector4f();
        Vector4f bbmax = new Vector4f();

        Vector4f c1 = new Vector4f(boundingBoxMin);
        Vector4f c2 = new Vector4f(boundingBoxMin);
        Vector4f c3 = new Vector4f(boundingBoxMin);
        Vector4f c4 = new Vector4f(boundingBoxMin);
        Vector4f c5 = new Vector4f(boundingBoxMax);
        Vector4f c6 = new Vector4f(boundingBoxMax);
        Vector4f c7 = new Vector4f(boundingBoxMax);
        Vector4f c8 = new Vector4f(boundingBoxMax);

        c2.x = boundingBoxMax.x;
        c3.y = boundingBoxMax.y;
        c4.z = boundingBoxMax.z;

        c6.x = boundingBoxMin.x;
        c7.y = boundingBoxMin.y;
        c8.z = boundingBoxMin.z;

        c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z));
        c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z));
        c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z));
        c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z));
        c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z));
        c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z));
        c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z));
        c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z));

        bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x)))))));
        bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x)))))));

        bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y)))))));
        bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y)))))));

        Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y));

        boolean tempNegativeDeterminant = GData.globalNegativeDeterminant;
        GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant;

        if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0)
                || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height)
                || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) {

            GL11.glPushMatrix();
            GL11.glMultMatrixf(matrix);

            if (c3d.isShowingLogo()) {
                if (filesWithLogo1.contains(shortName))
                    drawStudLogo1_GL20();
                else if (filesWithLogo2.contains(shortName))
                    drawStudLogo2_GL20();
            }

            GData data2draw = myGData;
            if (GData.accumClip > 0) {
                GData.accumClip++;
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20_CoplanarityHeatmap(c3d);
                GData.accumClip--;
            } else {
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20_CoplanarityHeatmap(c3d);
                if (GData.accumClip > 0)
                    GData.accumClip = 0;
            }

            GL11.glPopMatrix();

        }

        GData.globalNegativeDeterminant = tempNegativeDeterminant;

    }
}
 
Example 11
Source File: GData1.java    From ldparteditor with MIT License 4 votes vote down vote up
@Override
public void drawGL20_Wireframe(Composite3D c3d) {
    if (!visible)
        return;
    if (matrix != null) {

        final Rectangle bounds = c3d.getClientArea();
        final PerspectiveCalculator PC = c3d.getPerspectiveCalculator();

        Vector4f bbmin = new Vector4f();
        Vector4f bbmax = new Vector4f();

        Vector4f c1 = new Vector4f(boundingBoxMin);
        Vector4f c2 = new Vector4f(boundingBoxMin);
        Vector4f c3 = new Vector4f(boundingBoxMin);
        Vector4f c4 = new Vector4f(boundingBoxMin);
        Vector4f c5 = new Vector4f(boundingBoxMax);
        Vector4f c6 = new Vector4f(boundingBoxMax);
        Vector4f c7 = new Vector4f(boundingBoxMax);
        Vector4f c8 = new Vector4f(boundingBoxMax);

        c2.x = boundingBoxMax.x;
        c3.y = boundingBoxMax.y;
        c4.z = boundingBoxMax.z;

        c6.x = boundingBoxMin.x;
        c7.y = boundingBoxMin.y;
        c8.z = boundingBoxMin.z;

        c1.set(PC.getScreenCoordinatesFrom3D(c1.x, c1.y, c1.z));
        c2.set(PC.getScreenCoordinatesFrom3D(c2.x, c2.y, c2.z));
        c3.set(PC.getScreenCoordinatesFrom3D(c3.x, c3.y, c3.z));
        c4.set(PC.getScreenCoordinatesFrom3D(c4.x, c4.y, c4.z));
        c5.set(PC.getScreenCoordinatesFrom3D(c5.x, c5.y, c5.z));
        c6.set(PC.getScreenCoordinatesFrom3D(c6.x, c6.y, c6.z));
        c7.set(PC.getScreenCoordinatesFrom3D(c7.x, c7.y, c7.z));
        c8.set(PC.getScreenCoordinatesFrom3D(c8.x, c8.y, c8.z));

        bbmin.x = Math.min(c1.x, Math.min(c2.x, Math.min(c3.x, Math.min(c4.x, Math.min(c5.x, Math.min(c6.x, Math.min(c7.x, c8.x)))))));
        bbmax.x = Math.max(c1.x, Math.max(c2.x, Math.max(c3.x, Math.max(c4.x, Math.max(c5.x, Math.max(c6.x, Math.max(c7.x, c8.x)))))));

        bbmin.y = Math.min(c1.y, Math.min(c2.y, Math.min(c3.y, Math.min(c4.y, Math.min(c5.y, Math.min(c6.y, Math.min(c7.y, c8.y)))))));
        bbmax.y = Math.max(c1.y, Math.max(c2.y, Math.max(c3.y, Math.max(c4.y, Math.max(c5.y, Math.max(c6.y, Math.max(c7.y, c8.y)))))));

        Rectangle boundingBox = new Rectangle((int) bbmin.x, (int) bbmin.y, (int) (bbmax.x - bbmin.x), (int) (bbmax.y - bbmin.y));

        boolean tempNegativeDeterminant = GData.globalNegativeDeterminant;
        GData.globalNegativeDeterminant = GData.globalNegativeDeterminant ^ negativeDeterminant;

        if (boundingBox.intersects(bounds) || boundingBox.contains(0, 0) || boundingBox.contains(bounds.width, bounds.height) || boundingBox.contains(bounds.width, 0)
                || boundingBox.contains(0, bounds.height) || bounds.contains(boundingBox.x, boundingBox.y) || bounds.contains(boundingBox.x, boundingBox.y + boundingBox.height)
                || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y) || bounds.contains(boundingBox.x + boundingBox.width, boundingBox.y + boundingBox.height)) {

            GL11.glPushMatrix();
            GL11.glMultMatrixf(matrix);

            if (c3d.isShowingLogo()) {
                if (filesWithLogo1.contains(shortName))
                    drawStudLogo1_GL20();
                else if (filesWithLogo2.contains(shortName))
                    drawStudLogo2_GL20();
            }

            GData data2draw = myGData;
            if (GData.accumClip > 0) {
                GData.accumClip++;
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20_Wireframe(c3d);
                GData.accumClip--;
            } else {
                while ((data2draw = data2draw.next) != null && !ViewIdleManager.pause[0].get())
                    data2draw.drawGL20_Wireframe(c3d);
                if (GData.accumClip > 0)
                    GData.accumClip = 0;
            }

            GL11.glPopMatrix();

        }

        GData.globalNegativeDeterminant = tempNegativeDeterminant;

    }
}