In my libgdx android app I'm creating arrows with the following code
@Override
public void onAxonConnected(Pos one, Pos two) {
Model lineModel = build.createArrow(one.x, one.y, one.z, two.x, two.y, two.z, 0.15 f, 0.05 f, 5, GL20.GL_TRIANGLES, new Material(), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
ModelInstance line = new ModelInstance(lineModel);
this.addArrowModelInstanceToRender(line);
}
How can I prevent the longer arrows from becoming "fatter" than the shorter connection arrows?
I assume there is some multiplication going on somewhere, but I'd rather have them all rendering with the same width and arrow head size. Is that achievable with the createArrow function or do I have to roll my own model for that?
One solution would be to calculate the distance between the two vectors representing the start and end of the arrow, then pass that value in to the capLength and stemThickness multiplied or divided by a constant (or two).
Vector3 start = new Vector3(one.x, one.y, one.z);
Vector3 end = new Vector3(two.x, two.y, two.z);
float distance = start.dst(end);
Model lineModel = build.createArrow(one.x, one.y, one.z, two.x, two.y, two.z, CAP_LENGTH_CONSTANT / distance, STEM_THICKNESS_CONSTANT / distance, 5, GL20.GL_TRIANGLES, new Material(), VertexAttributes.Usage.Position | VertexAttributes.Usage.Normal);
You may need to test numbers a bit to find the right constants