BBC BASIC for Windows
Programming >> Graphics and Games >> 3D LEFT/ RIGHT Mouse controlled image Breakthrough
http://bb4w.conforums.com/index.cgi?board=graphics&action=display&num=1458040647

3D LEFT/ RIGHT Mouse controlled image Breakthrough
Post by michael on Mar 15th, 2016, 11:17am

All is progressing nicely.. A controlled 3D image

You need to be in the EXAMPLES\GRAPHICS folder in BBC Basic Directory to use this program since the B3D files are there and there is also the Library for the graphics.

Hold left or right mouse down to control the distance.
I will set up keyboard controls later since I know how to move it left and right too.
Code:
      MODE 8
      REM DIM l%(0), b%(1), n%(1), f%(1), s%(1), m%(1), t%(1), y(1), p(1), r(1), X(1), Y(1), Z(1), e(2), a(2)
      DIM l%(0), b%(1), n%(1), f%(1), s%(1), m%(1), t%(1), y(1), p(1), r(1), X(1), Y(1), Z(1), e(2), a(2)
      INSTALL @lib$+"D3DLIB"

      ON CLOSE PROCcleanup:QUIT
      ON ERROR PROCcleanup:PRINT REPORT$:END

      d% = FN_initd3d(@hwnd%, 1, 0)
      IF d% = 0 ERROR 100, "Can't initialise Direct3D"

      b%(0) = FN_load3d(d%, @dir$+"PYRAMID.B3D", n%(0), f%(0), s%(0))
      IF b%(0) = 0 ERROR 100, "Can't load PYRAMID.B3D"

      b%(1) = FN_load3d(d%, @dir$+"BASE.B3D", n%(1), f%(1), s%(1))
      IF b%(1) = 0 ERROR 100, "Can't load BASE.B3D"

      t%(1) = FN_loadtexture(d%, @dir$+"CLOCK.JPG")
      IF t%(1) = 0 ERROR 100, "Can't load CLOCK.JPG"
      e() = 0, 0, -6
      REM e() = 0, 0, -6
      a() = 0, 0, 0
      approach=-4
      dir$="away"
      REPEAT
        MOUSE xxxx,yyy,bbb
        IF bbb=4 THEN approach=approach -.005
        IF bbb=1 THEN approach=approach +.005
        p() = +2
        r() = 12.5
        X() = 0
        REM drive will move the object away from you at .001 steps in the world.. It can go slower.  * the drive variable is increasing. *  So to stop it you would just not increase its value. (having issues with it returning?)
        drive= drive+.001
  
        PROC_render(d%, &FF7F7F7F, 0, l%(), 2, m%(), t%(), b%(), n%(), f%(), s%(), y(), p(), r(), X(), Y(), Z(), e(), a(), approach, 5/4, 1, 1000)
        REM PROC_render(d%, &FF7F7F7F, 0, l%(), 2, m%(), t%(), b%(), n%(), f%(), s%(), y(), p(), r(), X(), Y(), Z(), e(), a(), drive, approach, 1, 1000)   REM hmmm why is this doing what it is?
        REM HERE IS YOUR OBJECT PARTS *******************t*****b*****n*****f*****s
        REM t%(1) is your clock texture
        REM b%(0) holds the Pyramid.B3D construct  n%(0),f%(0),s(0) --- Just the 3D Pyramid
        REM b%(1) holds the Base.B3D construct n%(1),f%(1),s%(1)  -- This is needed because if the texture was loaded on the pyramid it would cover all sides
        REM I will improve this program as I disect the render command
      UNTIL INKEY(1)=0
      END

      DEF PROCcleanup
      t%(1) += 0:IF t%(1) PROC_release(t%(1))
      b%(0) += 0:IF b%(0) PROC_release(b%(0))
      b%(1) += 0:IF b%(1) PROC_release(b%(1))
      d% += 0   :IF d%    PROC_release(d%)
      ENDPROC