|
IF INKEY$(-256)="W" INSTALL @lib$+"D3DLIBA" ELSE INSTALL @lib$+"OGLLIB" PROCcreate3d e%=0:d%=0 MODE 8 DIM l%(0), b%(3), n%(3), f%(3), s%(3), m%(3), t%(3), y(3), p(3), r(3), X(3), Y(3), Z(3), e(2), a(2) ON CLOSE PROCcleanup:QUIT ON ERROR PROCcleanup:PRINT REPORT$:END IF INKEY$(-256)="W" d% = FN_initd3d(@hwnd%, 1, 0) ELSE d% = FN_initgl(@hwnd%, 1, 0) IF d% = 0 ERROR 100, "Can't initialise Direct3D" b%(0) = FN_load3d(d%, @dir$+"button.FVF", n%(0), f%(0), s%(0)) IF b%(0) = 0 ERROR 100, "Can't load button.FVF" t%(0) = FN_loadtexture(d%, @dir$+"interface.jpg"):REM IF t%(0) = 0 ERROR 100, "Can't load texture" b%(1) = FN_load3d(d%,@dir$+"tinybutton.FVF",n%(1), f%(1), s%(1)) IF b%(1) = 0 ERROR 100, "Can't load button.FVF" t%(1) = FN_loadtexture(d%,@dir$+"GreenPointer.jpg"):REM Triangle number pointer ** IF t%(1) = 0 ERROR 100, "Can't load texture" b%(2) = FN_load3d(d%,@dir$+"tinybutton.FVF",n%(2), f%(2), s%(2)) IF b%(2) = 0 ERROR 100, "Can't load button.FVF" t%(2) = FN_loadtexture(d%,@dir$+"Blackdot.jpg") IF t%(2) = 0 ERROR 100, "Can't load texture" b%(3) = FN_load3d(d%,@dir$+"tinybutton.FVF",n%(3), f%(3), s%(3)) IF b%(3) = 0 ERROR 100, "Can't load button.FVF" t%(3) = FN_loadtexture(d%,@dir$+"Blackdot.jpg") IF t%(3) = 0 ERROR 100, "Can't load texture" REM b%(4) = FN_load3d(d%,@dir$+"button.FVF",n%(4), f%(4), s%(4)):REM 2 REM IF b%(4) = 0 ERROR 100, "Can't load button.FVF" REM t%(4) = FN_loadtexture(d%,@dir$+"2.jpg") REM IF t%(4) = 0 ERROR 100, "Can't load texture" e() = 0, 0, -6 a() = 0, 0, 0 REM l%()=1 :You aren't using any lighting, so don't need this. REPEAT y() =0:REM yaw (rotations around the Y axis) REM Z() depth REM Z(0) = -5: Y(0)=-0.7 :X(0)=-0.9 Z(0) = -4.6:Y(0)=-0.6:X(0)=-.8 REM Given this is constant, you don't need to have it inside the loop. REM You could achieve the same end with one object by changing the eye position Z coordinate. REM Better to use the Z array values to move objects relative to *each other* rather than relative to the eye position? X(3)=0.3 Y(3)=0 Z(3)=-4 X(1)=-0.4 Y(1)=-0.25 Z(1)=-4.7 REM Now render the 3D scene. Note that the number of objects (5th parameter) is 2, but all other arrays are 0-based (i.e. X(0) is the X position of the first object) PROC_render(d%, &FF7F7F7F, 0, l%(), 2, m%(), t%(), b%(), n%(), f%(), s%(), y(), p(), r(), X(), Y(), Z(), e(), a(), PI/4, 5/4, 1, 1000,0) :REM experimental WAIT 1 UNTIL INKEY(1)=0 PROCcleanup END : DEF PROCcleanup t%(0) += 0:IF t%(1) PROC_release(t%(1)) b%(0) += 0:IF b%(0) PROC_release(b%(0)) d% += 0 :IF d% PROC_release(d%) ENDPROC : DEF PROCcreate3d F% = OPENOUT"button.FVF" PROC4(6):REM 3 vertices PROC4(&140102):REM vertex size &18 and format &142 - change format to specify UV texture coordinates instead of colours, REM and allow the extra 4 bytes that requires (+8 for texture address, -4 for no colour) REM LL x LL y LL z u (x coord of texture) v (y coord of texture) PROC4(FN_f4(-0.5)):PROC4(FN_f4(-0.5)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)):PROC4(FN_f4(0.0)) REM LR x LR y LR z PROC4(FN_f4(0.5)):PROC4(FN_f4(-0.5)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)) REM PEAK X PEAK Y PEAK Z PROC4(FN_f4(0.5)):PROC4(FN_f4(0.5)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)) PROC4(FN_f4(-0.5)):PROC4(FN_f4(-0.5)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)):PROC4(FN_f4(0.0)) REM LR x LR y LR z PROC4(FN_f4(-0.5)):PROC4(FN_f4(0.5)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)):PROC4(FN_f4(1.0)) REM PEAK X PEAK Y PEAK Z PROC4(FN_f4(0.5)):PROC4(FN_f4(0.5)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)) CLOSE #F% F% = OPENOUT"tinybutton.FVF" PROC4(6):REM 3 vertices PROC4(&140102):REM vertex size &18 and format &142 - change format to specify UV texture coordinates instead of colours, REM and allow the extra 4 bytes that requires (+8 for texture address, -4 for no colour) REM LL x LL y LL z u (x coord of texture) v (y coord of texture) PROC4(FN_f4(-0.05)):PROC4(FN_f4(-0.05)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)):PROC4(FN_f4(0.0)) REM LR x LR y LR z PROC4(FN_f4(0.05)):PROC4(FN_f4(-0.05)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)) REM PEAK X PEAK Y PEAK Z PROC4(FN_f4(0.05)):PROC4(FN_f4(0.05)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)) PROC4(FN_f4(-0.05)):PROC4(FN_f4(-0.05)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)):PROC4(FN_f4(0.0)) REM LR x LR y LR z PROC4(FN_f4(-0.05)):PROC4(FN_f4(0.05)):PROC4(FN_f4(1.0)):PROC4(FN_f4(0.0)):PROC4(FN_f4(1.0)) REM PEAK X PEAK Y PEAK Z PROC4(FN_f4(0.05)):PROC4(FN_f4(0.05)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)):PROC4(FN_f4(1.0)) CLOSE #F% ENDPROC : DEF PROC4(A%):BPUT#F%,A%:BPUT#F%,A%>>8:BPUT#F%,A%>>16:BPUT#F%,A%>>24:ENDPROC