You are not logged in.

loki

Trainee

  • "loki" started this thread

Posts: 72

Location: Berlin

  • Send private message

1

Wednesday, January 19th 2022, 6:12am

drag hotspot along 3D hittestarea

Hi all,

could someone help solve my math puzzle for dragging hotspots in 3d space like in Klaus' Abu Simbel example, but along "flat" hittestareas, not in spherical motion?

Based on Klaus' example for vrhittesting (xml) I'm adding hotspots at the hitpoint position (red dot) in 3d space and get tx, ty, tz, and ath values of the hittestareas for the hotspots. I then would like to drag the hotspots along the corresponding hittestarea (considering the tx, ty, tz and ath values).

How does the math need to be adjusted in Klaus' Abu Simbel dragging code below?
Is it a different coordinate transformation than in this example or a different tx/ty/tz calculation?

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<action name="drag" scope="local">
		<!-- drag the spots around in 3D space -->
		copy(last_mouse_x, mouse.x);
		copy(last_mouse_y, mouse.y);
		copy(last_view_tx, view.tx);
		copy(last_view_ty, view.ty);
		copy(last_view_tz, view.tz);

		asyncloop(caller.pressed,
			<!-- kind of working condition for four-wall room -->

			if((caller.ath == 90) OR (caller.ath == '-90')
			, 
				trace('wall 1 or 3);
				copy(x, tempwalltx);
				calc(y, caller.ty - view.ty);	
				calc(z, caller.tz - view.tz);
			,
				trace('wall 2 or 4');
				calc(x, caller.tx - view.tx);
				calc(y, caller.ty - view.ty);	
				copy(z, tempwalltz);
			);
		
			spacetosphere(x,y,z, h,v,d);
			spheretoscreen(h,v, screen_x,screen_y);

			calc(screen_x, screen_x + (mouse.x - last_mouse_x));
			calc(screen_y, screen_y + (mouse.y - last_mouse_y));
			copy(last_mouse_x, mouse.x);
			copy(last_mouse_y, mouse.y);

			screentosphere(screen_x,screen_y, h,v);
			spheretospace(h,v,d, x,y,z);

			calc(caller.tx, x + view.tx + (view.tx - last_view_tx));
			calc(caller.ty, y + view.ty + (view.ty - last_view_ty));
			calc(caller.tz, z + view.tz + (view.tz - last_view_tz));
			copy(last_view_tx, view.tx);
			copy(last_view_ty, view.ty);
			copy(last_view_tz, view.tz);	
		);	
	</action>







I get good results for dragging along the hittestarea, but only close to the initial hotspot position, if I put the hittestarea tz or tx value as "z" or "x" in the beginning of the asyncloop, depending on ath (for 0/180 or for -90/90) of the hittestarea, but the further away the hotspot gets dragged from its initial position, the more the dragging effect decreases, because it still tries to go spherical I guess.

Does someone have an advise please?

This post has been edited 1 times, last edit by "loki" (Jan 20th 2022, 2:36am)