Global appheight=768Global appwidth=1024Global appdepth=32AppTitle "";,"Are you sure you want to quit?"Local SC_FPS=60 ;Desired framerateLocal rtime=Floor(1000.0/SC_FPS)Local ctime,limited=TrueLocal FPScount,FPStime,FPSframesGraphics3D appwidth,appheight,appdepth,6SetBuffer BackBuffer();Create an empty sceneLocal centrecam=CreatePivot()PositionEntity centrecam,0,25,0Local camera=CreateCamera(centrecam)PositionEntity camera,0,20,-50,1Local sun=CreateLight()PositionEntity sun,-100,400,0PointEntity sun,centrecamLocal ground=CreateMesh(),tiles=CreateSurface(ground)Local v1=AddVertex(tiles,-125,0,150),v2=AddVertex(tiles,125,0,150),v3=AddVertex(tiles,125,0,-100)AddTriangle(tiles,v1,v2,v3):v2=AddVertex(tiles,-125,0,-100):AddTriangle(tiles,v1,v3,v2)EntityColor ground,0,0,255Local block=CreateCube():ScaleMesh block,20,5,20Local linemesh=CreateMesh(camera),linesurf=CreateSurface(linemesh) ;The surface to use to draw the lines - single surface is always fasterEntityColor linemesh,255,0,0:EntityFX linemesh,1Local marker1=CreateSphere():PositionEntity marker1,-5,15,-5:EntityAlpha marker1,0.3 ;Mark the ends of the line in 3D spaceLocal marker2=CreateSphere():PositionEntity marker2,5,25,5:EntityAlpha marker2,0.3While Not KeyDown(1) ctime=MilliSecs() MoveEntity camera,0,KeyDown(200)-KeyDown(208),KeyDown(30)-KeyDown(44) TurnEntity centrecam,0,KeyDown(203)-KeyDown(205),0 PointEntity camera,centrecam RenderWorld ClearSurface linesurf ;If you redraw each frame as with standard drawing commands Draw3DLine(camera,linesurf,-5,15,-5,5,25,5,4) If MilliSecs()-FPStime=>1000 Then FPScount=FPSframes:FPSframes=0:FPStime=MilliSecs():Else FPSframes=FPSframes+1 Text 0,30,"FPS: "+FPScount Text 0,60,"Arrow keys to turn camera, A and Z to zoom" Delay (rtime-(MilliSecs()-ctime))-(limited+1) ;Free spare CPU time Flip limitedWendEndFunction Draw3DLine(camera,surf,x1#,y1#,z1#,x2#,y2#,z2#,thickness#=1,entity=0) ;If entity is not 0, points refer to an entity's local space TFormPoint x1,y1,z1,entity,camera x1=TFormedX() y1=TFormedY() z1=TFormedZ() Local d1#=Sqr(x1*x1+y1*y1+z1*z1)/GraphicsWidth() TFormPoint x2,y2,z2,entity,camera x2=TFormedX() y2=TFormedY() z2=TFormedZ() Local d2#=Sqr(x2*x2+y2*y2+z2*z2)/GraphicsWidth() Local theta#=ATan2(y2*(d1/d2)-y1,x2*(d1/d2)-x1) Local xTForm#=Cos(theta)*thickness Local yTForm#=Sin(theta)*thickness Local V0=AddVertex(surf,x1+yTForm*d1,y1-xTForm*d1,z1) Local V1=AddVertex(surf,x1-yTForm*d1,y1+xTForm*d1,z1) Local V2=AddVertex(surf,x2-yTForm*d2,y2+xTForm*d2,z2) Local V3=AddVertex(surf,x2+yTForm*d2,y2-xTForm*d2,z2) AddTriangle(surf,V0,V1,V2) AddTriangle(surf,V2,V3,V0)End Function
Global appheight=768Global appwidth=1024Global appdepth=32AppTitle "";,"Are you sure you want to quit?"Local SC_FPS=60 ;Desired framerateLocal rtime=Floor(1000.0/SC_FPS)Local ctime,limited=TrueLocal FPScount,FPStime,FPSframesGraphics3D appwidth,appheight,appdepth,6SetBuffer BackBuffer();Create an empty sceneLocal centrecam=CreatePivot()PositionEntity centrecam,0,25,0Local camera=CreateCamera(centrecam)PositionEntity camera,0,20,-50,1Local sun=CreateLight()PositionEntity sun,-100,400,0PointEntity sun,centrecamLocal ground=CreateMesh(),tiles=CreateSurface(ground)Local v1=AddVertex(tiles,-125,0,150),v2=AddVertex(tiles,125,0,150),v3=AddVertex(tiles,125,0,-100)AddTriangle(tiles,v1,v2,v3):v2=AddVertex(tiles,-125,0,-100):AddTriangle(tiles,v1,v3,v2)EntityColor ground,0,0,255Local block=CreateCube():ScaleMesh block,20,5,20Local linemesh=CreateMesh(camera),linesurf=CreateSurface(linemesh) ;The surface to use to draw the lines - single surface is always fasterEntityFX linemesh,1+2Local marker1=CreateSphere():PositionEntity marker1,-5,15,-5:EntityAlpha marker1,0.3 ;Mark the ends of the line in 3D spaceLocal marker2=CreateSphere():PositionEntity marker2,5,25,5:EntityAlpha marker2,0.3While Not KeyDown(1) ctime=MilliSecs() MoveEntity camera,0,KeyDown(200)-KeyDown(208),KeyDown(30)-KeyDown(44) TurnEntity centrecam,0,KeyDown(203)-KeyDown(205),0 PointEntity camera,centrecam RenderWorld ClearSurface linesurf ;If you redraw each frame as with standard drawing commands Draw3DLine(camera,linesurf,-5,15,-5,5,25,5,4,0,255,0,0) Draw3DLine(camera,linesurf,5,15,5,-5,25,-5,4,0,0,0,255) Draw3DLine(camera,linesurf,-5,15,5,5,25,-5,4,0,0,255,0) Draw3DLine(camera,linesurf,5,15,-5,-5,25,5,4,0,0,0,0) If MilliSecs()-FPStime=>1000 Then FPScount=FPSframes:FPSframes=0:FPStime=MilliSecs():Else FPSframes=FPSframes+1 Text 0,30,"FPS: "+FPScount Text 0,60,"Arrow keys to turn camera, A and Z to zoom" Delay (rtime-(MilliSecs()-ctime))-(limited+1) ;Free spare CPU time Flip limitedWendEndFunction Draw3DLine(camera,surf,x1#,y1#,z1#,x2#,y2#,z2#,thickness#=1,entity=0,colR=0,colG=0,colB=0) ;If entity is not 0, points refer to an entity's local space TFormPoint x1,y1,z1,entity,camera x1=TFormedX() y1=TFormedY() z1=TFormedZ() Local d1#=Sqr(x1*x1+y1*y1+z1*z1)/GraphicsWidth() TFormPoint x2,y2,z2,entity,camera x2=TFormedX() y2=TFormedY() z2=TFormedZ() Local d2#=Sqr(x2*x2+y2*y2+z2*z2)/GraphicsWidth() Local theta#=ATan2(y2*(d1/d2)-y1,x2*(d1/d2)-x1) Local xTForm#=Cos(theta)*thickness Local yTForm#=Sin(theta)*thickness Local V0=AddVertex(surf,x1+yTForm*d1,y1-xTForm*d1,z1) Local V1=AddVertex(surf,x1-yTForm*d1,y1+xTForm*d1,z1) Local V2=AddVertex(surf,x2-yTForm*d2,y2+xTForm*d2,z2) Local V3=AddVertex(surf,x2+yTForm*d2,y2-xTForm*d2,z2) VertexColor surf,V0,colR,colG,colB VertexColor surf,V1,colR,colG,colB VertexColor surf,V2,colR,colG,colB VertexColor surf,V3,colR,colG,colB AddTriangle(surf,V0,V1,V2) AddTriangle(surf,V2,V3,V0)End Function
;list where from originally, its only right!;http://www.blitzbasic.com/codearcs/codearcs.php?code=2590#commentsGlobal appheight=768Global appwidth=1024Global appdepth=32AppTitle "";,"Are you sure you want to quit?"Local SC_FPS=60 ;Desired framerateLocal rtime=Floor(1000.0/SC_FPS)Local ctime,limited=TrueLocal FPScount,FPStime,FPSframesGraphics3D appwidth,appheight,appdepth,6SetBuffer BackBuffer();Create an empty sceneLocal centrecam=CreatePivot()PositionEntity centrecam,0,25,0Local camera=CreateCamera(centrecam)PositionEntity camera,0,20,-50,1Local sun=CreateLight()PositionEntity sun,-100,400,0PointEntity sun,centrecamLocal ground=CreateMesh(),tiles=CreateSurface(ground)Local v1=AddVertex(tiles,-125,0,150),v2=AddVertex(tiles,125,0,150),v3=AddVertex(tiles,125,0,-100)AddTriangle(tiles,v1,v2,v3):v2=AddVertex(tiles,-125,0,-100):AddTriangle(tiles,v1,v3,v2)EntityColor ground,0,0,255Local block=CreateCube():ScaleMesh block,20,5,20Local linemesh=CreateMesh(camera),linesurf=CreateSurface(linemesh) ;The surface to use to draw the lines - single surface is always faster;Adjust the surface's colour here, or add vertex colours to the drawing function as necessaryLocal marker1=CreateSphere():PositionEntity marker1,-5,15,-5:EntityAlpha marker1,0.3 ;Mark the ends of the line in 3D spaceLocal marker2=CreateSphere():PositionEntity marker2,5,25,5:EntityAlpha marker2,0.3;my markerLocal marker3=CreateSphere():PositionEntity marker3,5,35,15:EntityAlpha marker3,0.3;three markers in a loopGlobal extrapoints=10Global threedgap = 9Dim marker(4)For create3 = 1 To extrapoints Local how_far_apart = 5 theNew=(threedgap*create3) ;theNew=create3 ;Local marker(create3)=CreateSphere() Local marker4=CreateSphere():PositionEntity marker4,5+theNew,35+theNew,15+theNew:EntityAlpha marker4,0.3 ;Local marker5=CreateSphere():PositionEntity marker4,5+theNew,35+theNew,15+theNew:EntityAlpha marker4,0.3 ;Local marker6=CreateSphere():PositionEntity marker4,5+theNew,35+theNew,15+theNew:EntityAlpha marker4,0.3 ;### following was an attempt.... ;PositionEntity marker(create3),5,35,15:EntityAlpha marker(create3),0.3 ;Local marker4=CreateSphere():PositionEntity marker4,5,35,15:EntityAlpha marker4,0.3 Nextextrapints=9For create4 = 1 To extrapints Local threedgap2 = -7 theNew=(threedgap2*create4) ;theNew=create3 ;Local marker(create3)=CreateSphere() Local marker5=CreateSphere():PositionEntity marker5,5+theNew,35+theNew,15:EntityAlpha marker4,0.3 ;Local marker5=CreateSphere():PositionEntity marker4,5+theNew,35+theNew,15+theNew:EntityAlpha marker4,0.3 ;Local marker6=CreateSphere():PositionEntity marker4,5+theNew,35+theNew,15+theNew:EntityAlpha marker4,0.3 ;### following was an attempt.... ;PositionEntity marker(create3),5,35,15:EntityAlpha marker(create3),0.3 ;Local marker4=CreateSphere():PositionEntity marker4,5,35,15:EntityAlpha marker4,0.3 NextWhile Not KeyDown(1) ctime=MilliSecs() MoveEntity camera,0,KeyDown(200)-KeyDown(208),KeyDown(30)-KeyDown(44) TurnEntity centrecam,0,KeyDown(203)-KeyDown(205),0 PointEntity camera,centrecam RenderWorld ClearSurface linesurf ;If you redraw each frame as with standard drawing commands Draw3DLine(camera,linesurf,-5,15,-5,5,25,5,4) ;introducing the third point Draw3DLine(camera,linesurf,5,25,5,5,35,15,4) ;;iterating through the others:- For only3 = 1 To extrapoints theLast=(threedgap*(only3-1)) theNew=(threedgap*only3) ;unfortunately this produces a linear thing at the mo, nevertheless - it works Draw3DLine(camera,linesurf,5+theLast,35+theLast,15+theLast,5+theNew,35+theNew,15+theNew,4) Next If MilliSecs()-FPStime=>1000 Then FPScount=FPSframes:FPSframes=0:FPStime=MilliSecs():Else FPSframes=FPSframes+1 Text 0,30,"FPS: "+FPScount Text 0,60,"Arrow keys to turn camera, A and Z to zoom" Delay (rtime-(MilliSecs()-ctime))-(limited+1) ;Free spare CPU time Flip limitedWendEndFunction Draw3DLine(camera,surf,x1#,y1#,z1#,x2#,y2#,z2#,thickness#=1,entity=0) ;If entity is not 0, points refer to an entity's local space TFormPoint x1,y1,z1,entity,camera x1=TFormedX() y1=TFormedY() z1=TFormedZ() Local d1#=Sqr(x1*x1+y1*y1+z1*z1)/GraphicsWidth() TFormPoint x2,y2,z2,entity,camera x2=TFormedX() y2=TFormedY() z2=TFormedZ() Local d2#=Sqr(x2*x2+y2*y2+z2*z2)/GraphicsWidth() Local theta#=ATan2(y2*(d1/d2)-y1,x2*(d1/d2)-x1) Local xTForm#=Cos(theta)*thickness Local yTForm#=Sin(theta)*thickness Local V0=AddVertex(surf,x1+yTForm*d1,y1-xTForm*d1,z1) Local V1=AddVertex(surf,x1-yTForm*d1,y1+xTForm*d1,z1) Local V2=AddVertex(surf,x2-yTForm*d2,y2+xTForm*d2,z2) Local V3=AddVertex(surf,x2+yTForm*d2,y2-xTForm*d2,z2) AddTriangle(surf,V0,V1,V2) AddTriangle(surf,V2,V3,V0)End Function