Beispiel #1
0
  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);
      }
    }
  }
Beispiel #2
0
  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();
  }
Beispiel #3
0
  @Override
  public void initialize(Context context, ProgramManager programManager) {
    lineShaderProgram = programManager.getProgram(ProgramManager.PROGRAM.LINE);

    textureDataHandler = TextureLoader.loadTexture(context, R.drawable.game209, GLES20.GL_LINEAR);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    int socketTextureDataHandler =
        TextureLoader.loadTexture(context, R.drawable.node_socket, GLES20.GL_LINEAR);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    mCorrectNodeTextureHandle =
        TextureLoader.loadTexture(context, R.drawable.game209, GLES20.GL_LINEAR);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    mWrongNodeTextureHandle =
        TextureLoader.loadTexture(context, R.drawable.game210, GLES20.GL_LINEAR);
    GLES20.glGenerateMipmap(GLES20.GL_TEXTURE_2D);

    mNodeBatch = new SpriteBatch(SpriteBatch.COLORED_VERTEX_3D, textureDataHandler);
    mNodeBatch.setFiltered(true);
    mNodeBatch.initialize(context, programManager);

    mSocketBatch = new SpriteBatch(SpriteBatch.VERTEX_3D, socketTextureDataHandler);
    mSocketBatch.setFiltered(true);
    mSocketBatch.useDepthTest(false);
    mSocketBatch.initialize(context, programManager);

    mConnectionsBatch = new Line3DBatch();
    mConnectionsBatch.initialize(context, programManager);

    mDottedBatch = new DottedLine3DBatch(0.7f, 0.8f);
    mDottedBatch.initialize(context, programManager);

    mSprite = new Sprite(Vector3f.getZero(), 2.0f, 2.0f);
    mSprite.setFiltered(true);
    mSprite.setTexture(textureDataHandler);
    mSprite.initialize(context, programManager);

    for (int i = 0; i < nodes.length; i++) {
      nodes[i].getSprite().setFiltered(true).initialize(context, programManager);
    }

    super.initialize(context, programManager);
  }