1
Programs / Re: Garland of pearls
« on: April 05, 2022, 03:32:44 pm »
I added another curiosity. (but I haven't covered the point yet)
I recently had a question with _MAPTRIANGLE that calculates 2d points. I wanted to know so I could move with a mouse in 3d. This has now been achieved with a simple solution.
Stretched mesh in 3d. Walkable with WASD + mouse like in 3D games. If you press the Q key, you can grab the point with the mouse and move it. You can nail it with the SPACE key.
I recently had a question with _MAPTRIANGLE that calculates 2d points. I wanted to know so I could move with a mouse in 3d. This has now been achieved with a simple solution.
Stretched mesh in 3d. Walkable with WASD + mouse like in 3D games. If you press the Q key, you can grab the point with the mouse and move it. You can nail it with the SPACE key.
Code: QB64: [Select]
- mouse_sens = .5
- tightness = 1
- gravity = .005
- lass = .94
- power = -0.3
- adj = .8 'moving speed 3d point mouse
- DIM SHARED monx, mony: monx = 800: mony = monx / _DESKTOPWIDTH * _DESKTOPHEIGHT: mon = _NEWIMAGE(monx, mony, 32): SCREEN mon: _FULLSCREEN: _MOUSEHIDE
- points_c_arr = 2000
- conn_c_arr = 2000
- make_grid 1, -10, -10, 10, 10, -10, 0, -10, 10, 0, 10, 10, 0, 1.5
- 'control
- mousex = 0: mousey = 0: mw = 0: WHILE _MOUSEINPUT: mousex = mousex + _MOUSEMOVEMENTX: mousey = mousey + _MOUSEMOVEMENTY: mw = mw + _MOUSEWHEEL: WEND
- 'calculate moving
- 'connections vector
- vec(0) = 0: vec(1) = 0: vec(2) = 0: vec_c = 0
- NEXT t2
- NEXT t
- NEXT a
- 'calculating points
- points(ap, 8) = points(ap, 0): points(ap, 9) = points(ap, 1): points(ap, 10) = points(ap, 2)
- rotate_display points(ap, 8), points(ap, 9), points(ap, 10)
- NEXT ap
- 'draw connections
- NEXT ac
- 'fix points draw signal
- NEXT ap
- 'take point with mouse
- take_sens = monx * 0.01: mindis = 999999: take = -1
- 'move with mouse 3d point
- NEXT ang2, ang1: points(take_moving, 0) = cx: points(take_moving, 1) = cy: points(take_moving, 2) = cz
- mess$ = "moving WASD+mouse Q-key fixing and moving point"
- SUB point3d_to_pset (x, y, z): zlimit = -2: x = monx * .5 + (x + zlimit) / -z * 400: y = mony * .5 + (y + zlimit) / z * 400
- tx1 = scale(x0, x1, n): ty1 = scale(y0, y1, n): tz1 = scale(z0, z1, n): tx2 = scale(x2, x3, n): ty2 = scale(y2, y3, n): tz2 = scale(z2, z3, n)
- points(l, 0) = scale(tx1, tx2, n): points(l, 2) = scale(ty1, ty2, n): points(l, 1) = scale(tz1, tz2, n)
- NEXT b, a
- points_c = points_c + resA * resB
- conn(conn_c, 2) = dis(conn(conn_c, 4), conn(conn_c, 5), conn(conn_c, 6)): conn(conn_c, 3) = 1: conn_c = conn_c + 1
- x = (x - cam(0)) * 100: y = (y - cam(2)) * 100: z = -(z - cam(1)) * 100: rotate_2d x, z, cam(13): rotate_2d y, z, cam(14)
- 'POINTS array
- '0,1,2 : XYZ
- '3,4,5 : XYZ vector
- '6:active 7:identifier
- '8,9,10 :XYZ calculated to maptriangle
- '11,12,13 :XYZ moving temporary calculating
- '14: 0:FIX 1:MOVING
- '15,16,17 2D-X,Y, greyscale
- 'CONN array
- '0:point#1
- '1:point#2
- '2:distance
- '3:active
- '4:disX
- '5:disY
- '6:disZ