Graphics3D 640,480,0,2lit = CreateLight(2)MoveEntity lit,0,-101,0SetBuffer BackBuffer()Global NTGox#Global NTGoz#Global NTGpixelwidth#Global NTGpixelheight#Global NTGinit = FalseGlobal NTGplaneGlobal NTGcamGlobal NTGheight#Global NTGrotation#Global NTGscalex# = 1Global NTGscaley# = 1Global NTGalpha# = 1Global NTGblend = 3Type NTGsprite Field entity,activeEnd TypeNTGinit2dAlpha();|||||||||||||||||||||||||||||||||||||||||||||||||||||||||;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||img1.NTGsprite = NTGLoadImage.NTGsprite("img1.jpg",256) ;PUT YOUR PICTURE HERE :) HOLD DOWN THE SPACE BAR AFTER YOU RUN THIS ONEWhile Not KeyDown(1)ClsDrawNTG img1.NTGsprite,MouseX(),MouseY()If KeyDown(57) Then NTGSetRotation MouseX() NTGsetalpha MouseY()/480.0EndIfUpdateWorld()RenderWorld()UpdateNTG().stt1If MilliSecs()-timer > 0 Then.stt x = 1000/(MilliSecs()-timer) If x > 58 Then Goto stt Text 1,1,xElse Goto stt1EndIftimer = MilliSecs()FlipWendFlipWaitKey();|||||||||||||||||||||||||||||||||||||||||||||||||||||||||;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||;|||||||||||||||||||||||||||||||||||||||||||||||||||||||||Function DrawNTG(hand.NTGsprite,x#,y#)ShowEntity handentityhandactive = TruePositionEntity handentity,NTGox# + x#*NTGpixelwidth#,0,NTGoz# + y#*NTGpixelheightRotateEntity handentity,0,NTGrotation#,0ScaleEntity handentity, NTGscalex#,1,NTGscaley#EntityAlpha handentity, NTGalpha#EntityBlend handentity, NTGblendEnd FunctionFunction UpdateNTG()For s.NTGsprite = Each NTGsprite sactive = False HideEntity sentityNextEnd FunctionFunction NTGSetBlend(bld) NTGblend = bldEnd FunctionFunction NTGSetRotation(Rot# = 0) NTGrotation = rot#End FunctionFunction NTGsetscale(sclx# = 1,scly# = 1) NTGscalex# = sclx# NTGscaley# = scly#End FunctionFunction NTGsetalpha(alph# = 1) NTGalpha# = alph#End FunctionFunction NTGCreateRect.NTGsprite(width#,height#,r = 255,g = 255,b = 255)tmptex = CreateTexture(64,64)SetBuffer TextureBuffer(tmptex)Color r,g,bRect 0,0,65,65,1SetBuffer BackBuffer()tmp.NTGsprite = New NTGspritetmpentity = CreateMesh()tmpsurf = CreateSurface(tmpentity)width# = width# / 2height# = height# / 2v1 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),0,0)v2 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),1,0)v3 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),1,1)v4 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),0,1)AddTriangle(tmpsurf,v3,v4,v2)AddTriangle(tmpsurf,v2,v4,v1);EntityColor tmpentity,r,g,bUpdateNormals tmpentityEntityTexture tmpentity, tmptexHideEntity tmpentityReturn tmp.NTGspriteEnd FunctionFunction NTGLoadImage.NTGsprite(imageext$,texw = 64)tmpimg = LoadImage(imageext$)width# = ImageWidth(tmpimg)height# = ImageHeight(tmpimg)ResizeImage tmpimg,texw,texwtmptex = CreateTexture(texw,texw)SetBuffer TextureBuffer(tmptex)DrawImage tmpimg,1,1SetBuffer BackBuffer()tmp.NTGsprite = New NTGspritetmpentity = CreateMesh()tmpsurf = CreateSurface(tmpentity)width# = width# / 2height# = height# / 2v1 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),0,0)v2 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),1,0)v3 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),1,1)v4 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),0,1)AddTriangle(tmpsurf,v3,v4,v2)AddTriangle(tmpsurf,v2,v4,v1);EntityColor tmpentity,r,g,bUpdateNormals tmpentityEntityTexture tmpentity, tmptexHideEntity tmpentityReturn tmp.NTGspriteEnd FunctionFunction NTGinit2dAlpha(maxrng# = 1000)NTGcam = CreateCamera()NTGinit = TrueIf NTGcam = 0 Then RuntimeError("Camera does not exist.")NTGplane = CreatePlane()TurnEntity NTGplane,-90,0,0MoveEntity NTGplane,0,-2,0EntityParent NTGplane,NTGcamEntityAlpha NTGplane,0EntityPickMode NTGplane,2CameraRange NTGcam,.01,maxrng#TurnEntity NTGcam,90,0,0MoveEntity NTGcam,0,0,100CameraZoom NTGcam,3CameraClsMode NTGcam,0,1CameraPick NTGcam,1,1x1# = PickedX()z1# = PickedZ()NTGheight# = PickedY()CameraPick NTGcam,GraphicsWidth(),GraphicsHeight()x2# = PickedX()z2# = PickedZ()NTGox# = x1#NTGoz# = z1#NTGpixelwidth# = (x2#-x1#)/GraphicsWidth()NTGpixelheight# = (z2#-z1#)/GraphicsHeight()End Function
Global NTGox#Global NTGoz#Global NTGpixelwidth#Global NTGpixelheight#Global NTGinit = FalseGlobal NTGplaneGlobal NTGcamGlobal NTGheight#Global NTGrotation#Global NTGscalex# = 1Global NTGscaley# = 1Global NTGalpha# = 1Global NTGblend = 1Global NTGBlue = 255Global NTGGreen = 255Global NTGRed = 255Global NTGorder = 0Type NTGsprite Field entity,active,texEnd TypeFunction DrawNTG(hand.NTGsprite,x#,y#,frm = 0)ShowEntity handentityhandactive = TruePositionEntity handentity,NTGox# + x#*NTGpixelwidth#,0,NTGoz# + y#*NTGpixelheightRotateEntity handentity,0,NTGrotation#,0ScaleEntity handentity, NTGscalex#,1,NTGscaley#EntityAlpha handentity, NTGalpha#EntityBlend handentity, NTGblendEntityColor handentity, NTGRed, NTGGreen, NTGBlueEntityTexture handentity,hand ex,frmEntityOrder handentity,NTGorderNTGorder = NTGorder - 1End FunctionFunction UpdateNTG()For s.NTGsprite = Each NTGsprite sactive = False HideEntity sentityNextNTGorder = 0End FunctionFunction NTGsetcolor(r,g,b)NTGred = rNTGgreen = gNTGblue = bEnd FunctionFunction NTGSetBlend(bld) NTGblend = bldEnd FunctionFunction NTGSetRotation(Rot# = 0) NTGrotation = rot#End FunctionFunction NTGsetscale(sclx# = 1,scly# = 1) NTGscalex# = sclx# NTGscaley# = scly#End FunctionFunction NTGsetalpha(alph# = 1) NTGalpha# = alph#End FunctionFunction NTGCreateRect.NTGsprite(width#,height#,r = 255,g = 255,b = 255)tmptex = CreateTexture(64,64)SetBuffer TextureBuffer(tmptex)Color r,g,bRect 0,0,65,65,1SetBuffer BackBuffer()tmp.NTGsprite = New NTGspritetmpentity = CreateMesh()tmpsurf = CreateSurface(tmpentity)width# = width# / 2height# = height# / 2v1 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),0,0)v2 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),1,0)v3 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),1,1)v4 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),0,1)AddTriangle(tmpsurf,v3,v4,v2)AddTriangle(tmpsurf,v2,v4,v1);EntityColor tmpentity,r,g,bUpdateNormals tmpentityEntityTexture tmpentity, tmptextmp ex = tmptexHideEntity tmpentityReturn tmp.NTGspriteEnd FunctionFunction NTGLoadImage.NTGsprite(imageext$)tmpimg = LoadImage(imageext$)width# = ImageWidth(tmpimg)height# = ImageHeight(tmpimg)tmptex = LoadTexture(imageext$,4)tmp.NTGsprite = New NTGspritetmpentity = CreateMesh()tmp ex = tmptextmpsurf = CreateSurface(tmpentity)width# = width# / 2height# = height# / 2v1 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),0,0)v2 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),1,0)v3 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),1,1)v4 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),0,1)AddTriangle(tmpsurf,v3,v4,v2)AddTriangle(tmpsurf,v2,v4,v1);EntityColor tmpentity,r,g,bUpdateNormals tmpentityEntityTexture tmpentity, tmptexHideEntity tmpentityReturn tmp.NTGspriteEnd FunctionFunction NTGLoadAnimImage.NTGsprite(imageext$,w,h,f,c)tmpimg = LoadImage(imageext$)width# = ImageWidth(tmpimg)height# = ImageHeight(tmpimg)tmptex = LoadAnimTexture(imageext$,4,w,h,f,c)tmp.NTGsprite = New NTGspritetmpentity = CreateMesh()tmp ex = tmptextmpsurf = CreateSurface(tmpentity)width# = width# / 2height# = height# / 2v1 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),0,0)v2 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,0-(height#*NTGpixelheight#),1,0)v3 = AddVertex(tmpsurf,(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),1,1)v4 = AddVertex(tmpsurf,0-(width#*NTGpixelwidth),NTGheight#,(height#*NTGpixelheight#),0,1)AddTriangle(tmpsurf,v3,v4,v2)AddTriangle(tmpsurf,v2,v4,v1);EntityColor tmpentity,r,g,bUpdateNormals tmpentityEntityTexture tmpentity, tmptexHideEntity tmpentityReturn tmp.NTGspriteEnd FunctionFunction NTGinit2dAlpha(maxrng# = 1000)NTGcam = CreateCamera()NTGinit = TrueIf NTGcam = 0 Then RuntimeError("Camera does not exist.")NTGplane = CreatePlane()TurnEntity NTGplane,-90,0,0MoveEntity NTGplane,0,-2,0EntityParent NTGplane,NTGcamEntityAlpha NTGplane,0EntityPickMode NTGplane,2CameraRange NTGcam,.01,maxrng#TurnEntity NTGcam,90,0,0MoveEntity NTGcam,0,0,100CameraZoom NTGcam,3CameraClsMode NTGcam,0,1CameraPick NTGcam,1,1x1# = PickedX()z1# = PickedZ()NTGheight# = PickedY()CameraPick NTGcam,GraphicsWidth(),GraphicsHeight()x2# = PickedX()z2# = PickedZ()NTGox# = x1#NTGoz# = z1#NTGpixelwidth# = (x2#-x1#)/GraphicsWidth()NTGpixelheight# = (z2#-z1#)/GraphicsHeight()lit = CreateLight(3)MoveEntity lit,0,-101,0TurnEntity lit,90,0,0End FunctionFunction EndNTG()For n.NTGsprite = Each NTGsprite FreeEntity nentity Delete n.NTGspriteNextEnd FunctionFunction ScaleImageFast(SrcImage, ScaleX#, ScaleY#, ExactSize=False) Local SrcWidth, SrcHeight Local DestWidth, DestHeight Local ScratchImage, DestImage Local SrcBuffer, ScratchBuffer, DestBuffer Local X1, Y1, X2, Y2 ; Get the width and height of the source image. SrcWidth = ImageWidth(SrcImage) SrcHeight = ImageHeight(SrcImage) ; Calculate the width and height of the dest image, or the scale. If ExactSize = False DestWidth = Floor(SrcWidth * ScaleX#) DestHeight = Floor(SrcHeight * ScaleY#) Else DestWidth = ScaleX# DestHeight = ScaleY# ScaleX# = Float(DestWidth) / Float(SrcWidth) ScaleY# = Float(DestHeight) / Float(SrcHeight) EndIf ; If the image does not need to be scaled, just copy the image and exit the function. If (SrcWidth = DestWidth) And (SrcHeight = DestHeight) Then Return CopyImage(SrcImage) ; Create a scratch image that is as tall as the source image, and as wide as the destination image. ScratchImage = CreateImage(DestWidth, SrcHeight) ; Create the destination image. DestImage = CreateImage(DestWidth, DestHeight) ; Get pointers to the image buffers. SrcBuffer = ImageBuffer(SrcImage) ScratchBuffer = ImageBuffer(ScratchImage) DestBuffer = ImageBuffer(DestImage) ; Duplicate columns from source image to scratch image. For X2 = 0 To DestWidth-1 X1 = Floor(X2 / ScaleX#) CopyRect X1, 0, 1, SrcHeight, X2, 0, SrcBuffer, ScratchBuffer Next ; Duplicate rows from scratch image to destination image. For Y2 = 0 To DestHeight-1 Y1 = Floor(Y2 / ScaleY#) CopyRect 0, Y1, DestWidth, 1, 0, Y2, ScratchBuffer, DestBuffer Next ; Free the scratch image. FreeImage ScratchImage ; Return the new image. Return DestImage End Function