public void drawAll(Camera cam) { float[] rotationMatrix = new float[16]; boolean typeSwitchDirty = false; OrderUnit[] renderOrder = buildCompleteDrawOrder(cam.getPos()); Matrix.setIdentityM(rotationMatrix, 0); Matrix.rotateM(rotationMatrix, 0, -angle, 0.0f, 1.0f, 0.0f); for (int i = 0; i < renderOrder.length; i++) { if (renderOrder[i].getType() == OrderUnit.ORDERUNITTYPE.Node) { if (!typeSwitchDirty) { mConnectionsBatch.endBatch(); mDottedBatch.endBatch(); } drawOneNode(renderOrder[i].getId(), rotationMatrix, cam); typeSwitchDirty = true; } else { if (typeSwitchDirty) { mConnectionsBatch.beginBatch(cam, modelMatrix); mDottedBatch.beginBatch(cam, modelMatrix); typeSwitchDirty = false; } Line3D currentLine = connections[renderOrder[i].getId()].getLine(); if (currentLine.isDotted()) mDottedBatch.batchElement(currentLine); else mConnectionsBatch.batchElement(currentLine); } } }
@Override public void draw(Camera cam) { Matrix.setIdentityM(modelMatrix, 0); Matrix.rotateM(modelMatrix, 0, angle, 0.0f, 1.0f, 0.0f); Camera updCam = new Camera(cam); updCam.setPos( cam.getPos() .rotate( -angle, 0.0f, 1.0f, 0.0f)); // camera position is changed WITHOUT updating matrices computeNodeSocketsPositions(updCam.getPos()); // TODO: redo enable/disable switch when performance optimizations are done // GLES20.glDisable(GLES20.GL_DEPTH_TEST); // GLES20.glEnable(GLES20.GL_DEPTH_TEST); drawConnections(updCam); // GLES20.glDisable(GLES20.GL_DEPTH_TEST); // GLES20.glEnable(GLES20.GL_DEPTH_TEST); drawNodes(updCam); // GLES20.glEnable(GLES20.GL_DEPTH_TEST); }
private void drawConnections(Camera cam) { NodeConnectionOrderUnit[] renderOrder = buildConnectionDrawOrder(cam.getPos()); mConnectionsBatch.beginBatch(cam, modelMatrix); mDottedBatch.beginBatch(cam, modelMatrix); for (int i = 0; i < renderOrder.length; i++) { Line3D currentLine = connections[renderOrder[i].getId()].getLine(); if (currentLine.isDotted()) mDottedBatch.batchElement(currentLine); else mConnectionsBatch.batchElement(currentLine); } mConnectionsBatch.endBatch(); mDottedBatch.endBatch(); }