public void drawNodesBatched(Camera cam) { int cur; TextureRegion texRgn = new TextureRegion(); float[] color; float[] spriteMatrix = new float[16]; float[] rotationMatrix = new float[16]; float[] convMatrix = new float[16]; Matrix.multiplyMM( convMatrix, 0, cam.getViewM(), 0, modelMatrix, 0); // multiply view matrix by model to calc distances from cam NodeOrderUnit[] renderOrder = this.buildDrawOrder(convMatrix); Matrix.setIdentityM(rotationMatrix, 0); Matrix.rotateM(rotationMatrix, 0, -angle, 0.0f, 1.0f, 0.0f); mNodeBatch.beginBatch(cam, rotationMatrix); // batch.beginBatch(cam); for (int i = 0; i < renderOrder.length; i++) { cur = renderOrder[i].getId(); /*if (nodes[cur].isSelected()) color = new float[] {0.1f, 0.1f, 0.7f, 1.0f}; else color = new float[] {1.0f, 1.0f, 1.0f, 1.0f};*/ switch (nodes[cur].getState()) { case CORRECT: color = new float[] {0.0f, 0.8f, 0.0f, 1.0f}; break; case WRONG: color = new float[] {0.8f, 0.0f, 0.0f, 1.0f}; break; case OPEN: color = new float[] {1.0f, 1.0f, 1.0f, 1.0f}; break; default: // when IDLE color = new float[] {0.7f, 0.7f, 0.7f, 1.0f}; break; } Matrix.setIdentityM(spriteMatrix, 0); Matrix.translateM( spriteMatrix, 0, modelMatrix, 0, nodes[cur].posX, nodes[cur].posY, nodes[cur].posZ); float diam = nodes[cur].getRadius() * 2; mNodeBatch.batchElement(diam, diam, color, texRgn, spriteMatrix); } mNodeBatch.endBatch(); }
public void drawNodes(Camera cam) { int cur; float[] color; float[] spriteMatrix = new float[16]; float[] rotationMatrix = new float[16]; float[] convMatrix = new float[16]; Matrix.multiplyMM( convMatrix, 0, cam.getViewM(), 0, modelMatrix, 0); // multiply view matrix by model to calc distances from cam NodeOrderUnit[] renderOrder = this.buildDrawOrder(convMatrix); Matrix.setIdentityM(rotationMatrix, 0); Matrix.rotateM(rotationMatrix, 0, -angle, 0.0f, 1.0f, 0.0f); for (int i = 0; i < renderOrder.length; i++) { cur = renderOrder[i].getId(); /*if (nodes[cur].isSelected()) color = new float[] {0.1f, 0.1f, 0.7f, 1.0f}; else color = new float[] {1.0f, 1.0f, 1.0f, 1.0f};*/ switch (nodes[cur].getState()) { case CORRECT: color = new float[] {0.0f, 0.8f, 0.0f, 1.0f}; nodes[cur].getSprite().setColor(color).setTexture(mCorrectNodeTextureHandle); break; case WRONG: color = new float[] {1.0f, 1.0f, 1.0f, 1.0f}; nodes[cur].getSprite().setColor(color).setTexture(mWrongNodeTextureHandle); break; case OPEN: color = new float[] {1.0f, 1.0f, 1.0f, 1.0f}; nodes[cur].getSprite().setColor(color).setTexture(mCorrectNodeTextureHandle); break; default: // when IDLE color = new float[] {0.7f, 0.7f, 0.7f, 1.0f}; nodes[cur].getSprite().setColor(color).setTexture(mCorrectNodeTextureHandle); break; } Matrix.setIdentityM(spriteMatrix, 0); Matrix.translateM( spriteMatrix, 0, modelMatrix, 0, nodes[cur].posX, nodes[cur].posY, nodes[cur].posZ); nodes[cur] .getSprite() .setModelMatrix(spriteMatrix) .setOrientationMatrix(rotationMatrix) .draw(cam); NodeConnectionSocket[] sockets = nodes[cur].getSockets(); mSocketBatch.beginBatch(cam, rotationMatrix); for (int k = 0; k < sockets.length; k++) { Matrix.setIdentityM(spriteMatrix, 0); Matrix.translateM( spriteMatrix, 0, modelMatrix, 0, nodes[cur].posX + sockets[k].posX, nodes[cur].posY + sockets[k].posY, nodes[cur].posZ + sockets[k].posZ); // sockets[k].getPosV().print("Debug", "Node " + i + " socket " + k); float diam = sockets[k].getRadius() * 2; mSocketBatch.batchElement(diam, diam, sockets[k].getSprite().getTexRgn(), spriteMatrix); } mSocketBatch.endBatch(); } }