Hi Tim!
Ok, let me take a try at it. I'm out most of the morning but will see what I can do after lunch.
Ok, let me take a try at it. I'm out most of the morning but will see what I can do after lunch.
'Compilable Example: #Compile Exe #Dim All #Include "Win32API.inc" Type PointX : X As Single : Y As Single : Z As Single : End Type %IDC_Graphic = 500 : %IDC_Timer = 501 Global hDlg As Dword, P() As PointX Function PBMain() Dialog New Pixels, 0, "3D Objects",,,200,200, %WS_SysMenu Or %WS_ClipChildren, To hDlg Control Add Graphic, hDlg, %IDC_Graphic, "", 10,10,180,180 Graphic Attach hDlg, %IDC_Graphic, ReDraw Graphic Color %Black, %rgb_Wheat Dialog Show Modal hDlg Call DlgProc End Function CallBack Function DlgProc() As Long Select Case Cb.Msg Case %WM_InitDialog LoadObject SetTimer(hDlg, %IDC_Timer, 40, %NULL) 'sends %WM_Timer to dialog callback Case %WM_Timer Graphic Clear : RotateXYZ : DrawObject : Graphic ReDraw End Select End Function Sub RotateXYZ Local i As Long, NewX As Single, NewY As Single, NewZ As Single, Angle As Single Angle = 0.05 For i = 1 To UBound(P) NewY = P(i).Y * Cos(Angle) - P(i).Z * Sin(Angle) 'X rotation NewZ = P(i).Y * Sin(Angle) + P(i).Z * Cos(Angle) 'X rotation P(i).Y = NewY : P(i).Z = NewZ NewX = P(i).Z * Sin(Angle) + P(i).X * Cos(Angle) 'Y rotation NewZ = P(i).Z * Cos(Angle) - P(i).X * Sin(Angle) 'Y rotation P(i).X = NewX : P(i).Z = NewZ NewX = P(i).X * Cos(Angle) - P(i).Y * Sin(Angle) 'Z rotation NewY = P(i).X * Sin(Angle) + P(i).Y * Cos(Angle) 'Z rotation P(i).X = NewX : P(i).Y = NewY Next i End Sub Sub DrawObject() Local i As Long, x1,x2,y1,y2, OffsetY, OffsetX As Long OffsetX = 90 : OffsetY = 90 For i = 1 To UBound(P) Graphic Ellipse (p(i).x-5+OffsetX,p(i).y-5+OffSetY)-(p(i).x+5+OffsetX,p(i).y+5+OffsetY),, %Red, %Red Next i End Sub Sub LoadObject ReDim P(4) P(1).x = -30 : P(1).y = -30 : P(1).z = -30 P(2).x = 30 : P(2).y = -30 : P(2).z = -30 P(3).x = 0 : P(3).y = -30 : P(3).z = 30 P(4).x = 0 : P(4).y = 0 : P(4).z = 30 End Sub 'gbs_00560 'Date: 03-10-2012
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment