Yes. At the time I took the screen shot I was just testing the basic principles of the matrix math & picture transform functions I wrote.
Shame Appleās killing OpenGL and Metal still isnāt a complete replacement for it. Woulda been nice if Apple kept up to date, mind you, that might have made OpenGL apps much faster than Metal⦠lolā¦
Ok⦠I donāt want/need to do anything fancy like OpenGL etc⦠This is supposed to be a one-off program to create a series of static images (ie. isometric dice)
for the image I posted above I can map the ORANGE and CYAN faces with acceptable results⦠but am still having issues with the TOP (magenta)
I have a series of images (128x128) and the approach I am taking is to scan each image (RGBSurface) then take the X,Y coordinate and the pixel color and attemp to map it to the face.
Here is the code (there are 9 images, as the 2,3 and 6 are rotated in some renderings)
Public Sub make_dice(index as string, value as integer, face1 as integer, face2 as integer)
Dim f As FolderItem
Dim x As Integer
Dim y As Integer
Dim i As Integer
Dim c As Color
Dim face As Picture
Dim face_r As RGBSurface
p=New picture(dice_size*1.74,dice_size*2.5)
face_dice=p.RGBSurface
For i = 1 To 3
Select Case i
Case 1
face=zGetImage(value)
Case 2
face=zGetImage(face1)
Case 3
face=zGetImage(face2)
End Select
//
face_r=face.RGBSurface
For x=0 To face.Width-1
For y=0 To face.height-1
c=face_r.Pixel(x,y)
Select Case i
Case 1
zMapTop(x,y,c)
Case 2
zMapLeft(x,y,c) // this works
Case 3
zMapRight(x,y,c) // this works
End Select
Next y
Next x
Next i
//
Select Case value
Case 7
value=2
Case 8
value=3
Case 9
value=6
End Select
f=GetFolderItem("").child("dice"+Str(value)+index+".png")
p.Save(f,picture.SaveAsPNG)
End Sub
Public Sub zMapLeft(old_x as double, old_y as double, c as color)
// calculate new x,y
Dim newX As Double
Dim newY As Double
newX = (p.width/2)-(old_x * Cos(angle))
newY = (p.height)-(old_x*Sin(angle))-old_y
face_dice.Pixel(newX,newY)=c
End Sub
Public Sub zMapRight(old_x as double, old_y as double, c as color)
// calculate new x,y
Dim newX As Double
Dim newY As Double
newX = (p.width/2)+(old_x * Cos(angle))
newY = (p.height)-(old_x*Sin(angle))-old_y
face_dice.Pixel(newX,newY)=c
End Sub
// THIS ONE IS WHERE THE PROBLEM IS
Public Sub zMapTop(old_x as double, old_y as double, c as color)
// calculate new x,y
Dim newX As Double
Dim newY As Double
Dim pcx As Double =(p.width/2)
Dim cx As Double = pcx-old_X
Dim cy As Double = pcx-old_y
newX = (cx * Cos(angle) - cy * Sin(angle))+ pcx
newY = (cy * Cos(angle) + cx * Sin(angle))
//
//newX=old_x
//newY=old_y
face_dice.Pixel(newX,newY)=c
End Sub
Calling the above as
make_dice("A",1,2,3)
renders this image
Solved
That feels like a lot of work to get a set of dice images when you can get polished ones as a set for (usually) about $15
Are you putting other images on, or was it just the dice faces?
This is how I wanted to do it⦠I donāt spend money on things I can do myself