Is there a way to draw a line between 2 vectors?

Hello everyone, I can’t find if Armory has a way to draw a line between 2 vectors, that would be really useful for me right now…2020-04-06 18_29_59

1 Like

Hi, there is an Armory3D library for this: VDebug. The project page has a good example on how to use it

2 Likes

There is also the line function in the DebugDraw class from Armory/Internal. To be able to use it you have to enable Debug Console under Flags in the Armory Exporter panel.

This is a function I “made” to be able to use that function by looking at this snippet from the DebugConsole class: https://github.com/armory3d/armory/blob/4c3332858ef0f397d898b3050fd86f80e47868eb/Sources/armory/trait/internal/DebugConsole.hx#L83

	var from = new iron.math.Vec4();
	var to = new iron.math.Vec4();

	var draw = false;
	function drawLine() {
		if (!draw) {
			draw = true;
			armory.trait.internal.DebugDraw.notifyOnRender(function(draw: armory.trait.internal.DebugDraw) {
				draw.line(from.x, from.y, from.z, to.x, to.y, to.z);
			});
		}
	}

To use it call drawLine in notifyOnStart and then set from and to values respectively to draw a line and set them to equal values to hide the line (like (0,0,0) to both).
Hope it helps.

Full example:

package arm;

class MyTrait extends iron.Trait {
	public function new() {
		super();

		notifyOnInit(function() {
			drawLine();
		});
		 notifyOnUpdate(function() {
			from.set(0.0, 0.0, 0.0);
			to.set(1.0, 1.0, 1.0);
		 });
	}

	
	var from = new iron.math.Vec4();
	var to = new iron.math.Vec4();

	var draw = false;
	function drawLine() {
		if (!draw) {
			draw = true;
			armory.trait.internal.DebugDraw.notifyOnRender(function(draw: armory.trait.internal.DebugDraw) {
				draw.line(from.x, from.y, from.z, to.x, to.y, to.z);
			});
		}
	}
}
2 Likes