Help for testing nodes in Android

Hello! I am trying to add multi touch functionality On Canvas Element node and creating a node like Pick Object but with multi touch and not caring about coords.

Unfortunately i can’t get a successful build in Android Studio (like two hours trying and don’t get it). I’ve made a publish project with the test setup, so if anyone can test it for me would be good!

I expect the objects touched to go into the array and also its hit locations, so if this works then i will start to look into On Canvas Element node in the same fashion.

I’ve added the Virtual Gamepad trait to see if it works with multitouch, so if it don’t report and now is the time to fix it.

The node design is here, feel free to make suggestions:

Screenshot from 2021-07-10 10-55-55

Please, try to build-run the project or send me an APK

2 Likes

Hi, So I wanted to try building your project for Android. Unfortunately, I get the same error as I mentioned on GitHub about Kore:Mouse:Unlock in Android Studio. Even for the default cube.

Were you able to build the default cube for Android?

I get the same error as I mentioned on GitHub about Kore:Mouse:Unlock in Android Studio.

Then it is not related to that Uniform Manager fix, because this build have the fix on it.

Were you able to build the default cube for Android?

I am unable to build anything because i guess something is broken for Linux in the published build files. I got an error Invalid gradle jdk configuration found in Android Studio trying to build Armory app, but i can build an empty project without problems, idk what is happening. I don’t use Android Studio for a long time…

What would be the best way to track the Kore:Mouse:Unlock issue? This looks a kha issue for me, maybe we could try another version of it

1 Like

Yes, I understand that this is not related to UniformsManager.

May be I’m a bit confused but, the files you shared are a blend file and node scripts. It was not a build of the project.

Do you mean build in Android Studio or build in Blender, Armory?

Yes, seems like so. Maybe some kind of version miss-match

1 Like

May be I’m a bit confused but, the files you shared are a blend file and node scripts. It was not a build of the project.

The confusion was mine, i had uploaded the wrong file. I fixed it in case you want to try again :slight_smile:

Do you mean build in Android Studio or build in Blender, Armory?

I mean i can build an empty project in AndroidStudio, but no one existent published from Armory. I will try to solve this soon

Yes, seems like so. Maybe some kind of version miss-match

I really hope is that the case

Okay, I had to modify the cmake.txt file in the build files to get it to start building in Android Studio, since it was pointing to files on your system…

Even then, I was unable to get it to fully build in Android studio because of the same “Kore” errors.

I’m opening a GitHub issue for it now!

Once this is fixed, I am sure I can test your files.

1 Like

Are you opening the correct folder when opening the project in Android Studio? Also, see if any of the answers works for you android - Invalid Gradle JDK configuration found? - Stack Overflow

2 Likes

Are you opening the correct folder when opening the project in Android Studio?

I guess yes, i open this file:

Screenshot from 2021-07-16 15-04-30

I’ve already tryed to specify the JDK location, but it is already correctly before i change it:

I don’t think it is an error from my side, because i can create a new Empty project in AndroiStudio and build it as usually.

Maybe it is also the different version issue that manifests itself differently for me or something broken the build process for Linux there :confused:

Anyway i guess the node should work (at least by reading the code, it is uggly but i didn’t see nothing wrong)

package armory.logicnode;

import kha.input.Surface;
import iron.math.Vec4;
import iron.object.Object;

class GetObjectsOnTouchNode extends LogicNode {

	var maxTouches: Int;

	var mask: Int;
	var hits = new Array<Vec4>();
	var objects = new Array<Object>();

	#if arm_physics
	var physics: Null<armory.trait.physics.PhysicsWorld>;
	#end

	public function new(tree: LogicTree) {
		super(tree);

		#if (kha_android || kha_ios)
		if (kha.input.Surface.get() != null) kha.input.Surface.get().notify(onTouchStart, onTouchEnd, onTouchMove);
		#end
	}

	override function get(from: Int): Dynamic {
		#if (kha_android || kha_ios)
		maxTouches = inputs[0].get();
		mask = inputs[1].get();
		#end

		#if arm_physics
		physics = armory.trait.physics.PhysicsWorld.active;

		if (objects.length == 0) {
 			return null;
		}

		if (from == 0) {
			return objects;

		} else {
			return hits;
		}
		#end

		return null;
	}

	function onTouchStart(index: Int, x: Int, y: Int) {
		if (index > maxTouches - 1) {
			return;
		}

		#if arm_physics
		if (physics == null) {
			return;
		}

		var rb: Null<armory.trait.physics.RigidBody> = physics.pickClosest(x, y, mask);

		if (rb != null) {
			objects.push(rb.object);
			hits.push(physics.hitPointWorld);
		}
		#end
	}

	function onTouchEnd(index: Int, x: Int, y: Int) {
		if (index > objects.length - 1) {
			return;
		}

		#if arm_physics
		if (physics == null) {
			return;
		}

		objects.remove(objects[index]);
		hits.remove(hits[index]);
		#end
	}

	function onTouchMove(index: Int, x: Int, y: Int) {}
}
2 Likes