11-20-2022, 04:58 AM
I've been trying to make this work but I'm stumped.
I messed around with a 3d points program by MasterGy and managed to get a sense of the space and coordinates. There's something that I can't seem to grasp though...that's placing an image onto a surface (using _maptriangle).
In this program, I wanted to place an image on the 'floor'. So I started by placing about 600 small tiles in a grid, exactly where I want to place the image. But images always rotate towards the viewer. Even the small tiles do this. The grid of tiles (as a whole) doesn't do this - only each individual tile. How to lay the image flat is what I'm trying to figure out.
So if anyone here knows how this works....
I'll attach the image I'm trying to use but any 750x750 image will do.
I messed around with a 3d points program by MasterGy and managed to get a sense of the space and coordinates. There's something that I can't seem to grasp though...that's placing an image onto a surface (using _maptriangle).
In this program, I wanted to place an image on the 'floor'. So I started by placing about 600 small tiles in a grid, exactly where I want to place the image. But images always rotate towards the viewer. Even the small tiles do this. The grid of tiles (as a whole) doesn't do this - only each individual tile. How to lay the image flat is what I'm trying to figure out.
So if anyone here knows how this works....
I'll attach the image I'm trying to use but any 750x750 image will do.
Code: (Select All)
'Modified 3d points program by MasterGy
Screen _NewImage(1000, 600, 32)
whitewall = _NewImage(1000, 600, 32)
Line (1, 1)-(1000, 600), _RGB(180, 180, 180), BF
_PutImage (1, 1)-(1000, 600), 0, whitewall, (1, 1)-(1000, 600)
Cls
bluewall = _NewImage(100, 100, 32)
Line (1, 1)-(100, 100), _RGB(10, 10, 20), BF
_PutImage (1, 1)-(100, 100), 0, bluewall, (1, 1)-(100, 100)
octo = _LoadImage("octo.png", 32)
wall2 = _CopyImage(whitewall, 33)
floor = _CopyImage(bluewall, 33)
floor2 = _CopyImage(octo, 33)
'create spectator
Dim Shared sp(6)
sp(0) = 500
sp(1) = 1500
sp(2) = 400
sp(3) = 0 'looking in the direction of the observer XZ
sp(4) = 0 'looking in the direction of the observer YZ
sp(5) = 1 'multiplier X-Y see
sp(6) = 1 'multiplier Z see
'create screen
scr = _NewImage(1000, 1000 / _DesktopWidth * _DesktopHeight, 32)
Screen scr
_MouseHide
_FullScreen
_Dest scr
_DisplayOrder _Hardware , _Software
Do
_Limit 40
_PutImage (1, 1), wall2
'draw floor tiles
For ctx = 1 To 500 Step 20
For cty = 1 To 500 Step 20
ps = 2
x = 0 + ps * ctx
y = 0 + ps * cty
z = 530
rotate_to_maptriangle x, y, z 'position of floor tiles from the point of view of the observer
_MapTriangle (0, 0)-(100, 0)-(0, 100), floor To(x - ps, y - ps, z)-(x + ps, y - ps, z)-(x - ps, y + ps, z)
_MapTriangle (100, 100)-(100, 0)-(0, 100), floor To(x + ps, y + ps, z)-(x + ps, y - ps, z)-(x - ps, y + ps, z)
Next cty
Next ctx
'draw octo floor
ps = 500
x = 500
y = 500
z = 30
rotate_to_maptriangle x, y, z 'octo floor
_MapTriangle (0, 0)-(750, 0)-(0, 750), floor2 To(x - ps, y - ps, z)-(x + ps, y - ps, z)-(x - ps, y + ps, z), , _Smooth
_MapTriangle (750, 750)-(750, 0)-(0, 750), floor2 To(x + ps, y + ps, z)-(x + ps, y - ps, z)-(x - ps, y + ps, z), , _Smooth
_Display
'mouse input axis movement and mousewheel
mousex = mousex * .6
mousey = mousey * .6
mw = 0
While _MouseInput: mousex = mousex + _MouseMovementX: mousey = mousey + _MouseMovementY: mw = mw + _MouseWheel: Wend 'movement data read
'control spectator
mouse_sens = .001 'mouse rotating sensitive
sp(3) = sp(3) - mousex * mouse_sens
sp(4) = sp(4) + mousey * mouse_sens
If Abs(sp(4)) > _Pi / 2 Then sp(4) = _Pi / 2 * Sgn(sp(4))
vec_x = (Sin(sp(3)) * (Cos(sp(4) + _Pi)))
vec_y = (Cos(sp(3)) * (Cos(sp(4) + _Pi)))
vec_z = -Sin(sp(4) + _Pi)
speed = 40 'moving speed
moving = Abs(_MouseButton(1) Or _KeyDown(Asc("w"))) * speed - Abs(_MouseButton(2) Or _KeyDown(Asc("s"))) * speed
sp(0) = sp(0) + vec_x * moving
sp(1) = sp(1) + vec_y * moving
sp(2) = sp(2) + vec_z * moving
Loop Until _KeyDown(27)
Sub rotate_to_maptriangle (x, y, z)
x2 = x - sp(0)
y2 = y - sp(1)
z2 = z - sp(2)
rotate_2d x2, y2, sp(3)
rotate_2d y2, z2, sp(4) + _Pi / 2
x = x2 * sp(5)
y = y2 * sp(5)
z = z2 * sp(6)
End Sub
Sub rotate_2d (x, y, ang)
x1 = x * Cos(ang) - y * Sin(ang)
y1 = x * Sin(ang) + y * Cos(ang)
x = x1: y = y1
End Sub