02-15-2024, 08:45 PM
unfortunately, I cannot adapt to the above program. I don't use '_mem'. I don't understand why it is so. I can't help you on that thread
If you want to display a cube/brick simply, I have put together a quick solution for you. you can use the size (width, length, height), position and rotation of the blocks.
If you want to display a cube/brick simply, I have put together a quick solution for you. you can use the size (width, length, height), position and rotation of the blocks.
Code: (Select All)
'creating hardware images of different colors (you can also use loadimage(...,33) . These will be the sides of the brick
temp = _NewImage(1, 1, 32): _Dest temp: PSet (0, 0), _RGB32(255, 0, 0): t1 = _CopyImage(temp, 33): _FreeImage temp
temp = _NewImage(1, 1, 32): _Dest temp: PSet (0, 0), _RGB32(0, 255, 0): t2 = _CopyImage(temp, 33): _FreeImage temp
temp = _NewImage(1, 1, 32): _Dest temp: PSet (0, 0), _RGB32(0, 0, 255): t3 = _CopyImage(temp, 33): _FreeImage temp
temp = _NewImage(1, 1, 32): _Dest temp: PSet (0, 0), _RGB32(255, 0, 255): t4 = _CopyImage(temp, 33): _FreeImage temp
temp = _NewImage(1, 1, 32): _Dest temp: PSet (0, 0), _RGB32(255, 255, 0): t5 = _CopyImage(temp, 33): _FreeImage temp
temp = _NewImage(1, 1, 32): _Dest temp: PSet (0, 0), _RGB32(0, 255, 255): t6 = _CopyImage(temp, 33): _FreeImage temp
sc = _NewImage(800, 800, 32): Screen sc: _Dest sc
'draw_cube params
'values 1,2,3 are the coordinate points
'values 4,5,6 are the dimensions of the brick (width, length, height)
'values 7-12 you will draw these harweres textures on the side of the brick
'13 angle, rotating XY plane
'14 angle, rotating XZ plane
Do: _Limit 30
draw_brick 10, 10, -50, 5, 5, 5, t1, t2, t3, t4, t5, t6, 0, 0
draw_brick -10, 10, -50, 5, 5, 5, t1, t2, t3, t4, t5, t6, 0, 0
draw_brick 10, -10, -50, 5, 5, 5, t1, t2, t3, t4, t5, t6, rotating, 0
draw_brick -10, -10, -50, 5, 5, 10, t1, t2, t3, t4, t5, t6, 0, rotating
rotating = rotating + .1
_Display
Loop
Sub draw_brick (x, y, z, sizex, sizey, sizez, t0, t1, t2, t3, t4, t5, rota, rotb)
Dim c(2): c(0) = x: c(1) = y: c(2) = z
Dim size(2): size(0) = sizex: size(1) = sizey: size(2) = sizez
Dim t(5): t(0) = t0: t(1) = t1: t(2) = t2: t(3) = t3: t(4) = t4: t(5) = t5
Dim p(3, 2), pc(7, 2), sq(3) As _Unsigned _Byte
For t = 0 To 7
For c = 0 To 2: pc(t, c) = size(c) * (Sgn(t And 2 ^ c) * 2 - 1): Next c
rotate_2d pc(t, 0), pc(t, 1), rota
rotate_2d pc(t, 0), pc(t, 2), rotb
For c = 0 To 2: pc(t, c) = pc(t, c) + c(c): Next c
Next t
For t = 0 To 5
For q = 0 To 3: s = Val(Mid$("-0246-1357-0145-2367-0123-4567", 2 + t * 5 + q, 1))
For b = 0 To 2: p(q, b) = pc(s, b): Next b, q
wtext = _Width(t(t)) - 1: htext = _Height(t(t)) - 1
_MapTriangle (0, 0)-(wtext, 0)-(0, htext), t(t) To(p(0, 0), p(0, 1), p(0, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _Smooth
_MapTriangle (wtext, htext)-(wtext, 0)-(0, htext), t(t) To(p(3, 0), p(3, 1), p(3, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _Smooth
Next t
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