Small Basic 3D

Nomestack 61 Reputation points
2021-08-20T19:48:39.727+00:00

hi, i'm doing some tests in ld3dview and i should this code work right?

While ("True")
Program.Delay(10)
pos = LD3DView.GetPosition(view3D,cube)
pos[1] = pos[1] + 0.5
LD3DView.TranslateGeometry(view3D,cube,pos[1],pos[2],pos[3])
EndWhile

but it doesn't work and the cube keeps "flicking"
can someone tell me why?

Developer technologies | Small BASIC
{count} votes

1 answer

Sort by: Most helpful
  1. Scout 541 Reputation points
    2021-08-21T16:03:27.94+00:00

    I have extended tryhest's program RotoCubes with an animation that uses "LD3DView.GetPosition" and "LD3DView.TranslateGeometry".

    125210-black-cubes-small.png
    The mouse functions and the "Shift" and "Ctrl" keys can be used for navigation.

    LDUtilities.CurrentCulture = "en-us"  
    GraphicsWindow.Width=900  
    GraphicsWindow.Height=GraphicsWindow.Width  
    sset()  
    GraphicsWindow.Title="RotoCubes"  
    GraphicsWindow.BackgroundColor ="Black"  
      
    view3D = LD3DView.AddView(600,600,"True") 'Will not clip to size if window rescaled'  
    LD3DView.AddDirectionalLight(view3D,"white",1,1,1)  
    LD3DView.AddAmbientLight(view3D,"#88aabbcc")  
    LD3DView.AutoControl ("true" "true",-1,3)  
    LD3DView.ResetCamera(view3D,-100,50,60, 5, 0, -3, "","","")  
    rf=1  
    For x=1 to 3  
      For y=1 To 3  
        cc[x][y]=LD3DView.AddCube (view3D 5 "Black" "D")  
        LD3DView.AddImage (view3D cc[x][y] "" im[x][y] "D")  
        LD3DView.TranslateGeometry (view3D  cc[x][y], -x*10, 0 , -y*10)  
        LD3DView.AnimateRotation  (view3D  cc[x][y] 0 0 1 0 360*rf 3 ,-1)  
        rf=rf*(-1)  
    EndFor   
    endfor  
      
    While ("True")  
     For x=1 to 3  
        For y=1 To 3  
          For Z = 1 To 90  
            pos = LD3DView.GetPosition(view3D,cc[x][y])  
            pos[3]= pos[3] + 0.707  
            LD3DView.TranslateGeometry(view3D,cc[x][y],pos[1],pos[2],pos[3])  
            Program.Delay(8)  
          Endfor  
        EndFor   
      endfor      
     Program.Delay(2000)  
     For x=3 to 1 Step -1  
        For y=3 To 1 Step -1  
          For Z = 1 To 90  
            pos = LD3DView.GetPosition(view3D,cc[x][y])  
            pos[3]= pos[3] - 0.707  
            LD3DView.TranslateGeometry(view3D,cc[x][y],pos[1],pos[2],pos[3])  
            Program.Delay(8)  
          Endfor  
        EndFor   
      endfor      
      Program.Delay(2000)  
    EndWhile  
      
    Sub sset  
      'ii=Flickr.GetRandomPicture ("sun")'  
      'img= ImageList.LoadImage (ii)'  
      img= ImageList.LoadImage (Program.Directory + "\Glimmer_of_SB.jpg")  
      LDImage.Resize (img 400 400)  
      im0=LDImage.Copy(img)  
      im=LDImage.SplitImage (img 3 3)  
      i=1  
      ys=ImageList.GetHeightOfImage (im[1][2])+2  
      xs=ImageList.GetWidthOfImage  (im[1][3])+2  
      For x=1 To 3  
        For y=1 To 3  
          mm[i] = Shapes.AddImage  (im[x][y])  
          Shapes.Move (mm[i] (x-1)*xs (y-1)*ys)  
          LDShapes.SetShapeEvent (mm[i])  
          amm[x][y]=i  
          i=i+1  
        EndFor   
      EndFor   
    EndSub   
    

    The program needs the picture in the program directory
    "Glimmer_of_SB.JPG"

    125281-glimmer-of-sb.jpg

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.