Here, try this:
I've made a mesh-based version of the sprite commands.
To use them, copy everything from the line 'MESH-BASED SPRITE COMMANDS' into your program.
Two commands are different:
'UpdateSprites' should be called before RenderWorld, to enable the SpriteViewModes, and 'FreeSprite' should be used instead of FreeEntity.
; CreateSphere Example ; -------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() piv=CreatePivot() camera=CreateCamera(piv) MoveEntity camera, 0, 0, -2 textu = CreateTexture(80, 15) SetBuffer TextureBuffer(Textu) ClsColor 255, 0, 0 Cls Text 1,1, "no" SetBuffer BackBuffer() Sprite = CreateSprite() EntityTexture Sprite, Textu ScaleSprite sprite, 0.5, 0.1 SpriteViewMode sprite, 1 FreeTexture Textu EntityPickMode Sprite, 2 ;EntityRadius sprite, 0.13, 0.9 ;create spheres For i = 0 To 1000 ok = CreateSphere() PositionEntity ok, Rnd(-100, 100), Rnd(-100, 100), Rnd(-100, 100) EntityColor ok, Rand(255), Rand(255), Rand(255) Next Repeat TurnEntity piv, 0, 1, 0 UpdateSprites(camera) RenderWorld CameraPick camera, MouseX(), MouseY() Color 255, 255, 255 Text 0, 0, "you picked: " + PickedEntity() Flip Until KeyHit(1) End ;----------------------------------------------------------------------------------------------------- ; MESH-BASED SPRITE COMMANDS ;----------------------------------------------------------------------------------------------------- Type Sprites Field mesh Field view End Type ;----------------------------------------------------------------------------------------------------- ; LoadSprite() ;----------------------------------------------------------------------------------------------------- Function LoadSprite(filename$, texflag = 9, parent = 0) tex = LoadTexture(filename$, texflag) mesh = CreateMesh(parent) surf = CreateSurface(mesh) AddVertex surf, -1, -1, 0, 1, 1 AddVertex surf, +1, -1, 0, 0, 1 AddVertex surf, +1, +1, 0, 0, 0 AddVertex surf, -1, +1, 0, 1, 0 AddTriangle surf, 0, 1, 2 AddTriangle surf, 0, 2, 3 ;double sided method I, works with PickMode 2 ;AddTriangle surf, 2, 1, 0 ;AddTriangle surf, 3, 2, 0 If tex <> 0 Then EntityTexture mesh, tex FreeTexture tex End If ;double sided method II, could give problems with PickMode 2 EntityFX mesh, 16 s.Sprites = New Sprites s\mesh = mesh Return mesh End Function ;----------------------------------------------------------------------------------------------------- ; ScaleSprite() ;----------------------------------------------------------------------------------------------------- Function ScaleSprite(sp, x#, y#) ScaleEntity sp, x, y, 1 End Function ;----------------------------------------------------------------------------------------------------- ; RotateSprite() ;----------------------------------------------------------------------------------------------------- Function RotateSprite(sp, x#) RotateEntity sp, 0, 0, x, 1 End Function ;----------------------------------------------------------------------------------------------------- ; HandleSprite() ;----------------------------------------------------------------------------------------------------- Function HandleSprite(sp, x#, y#) PositionMesh sp, x, y, 0 End Function ;----------------------------------------------------------------------------------------------------- ; SpriteViewMode() ;----------------------------------------------------------------------------------------------------- Function SpriteViewMode(sp, vm) For s.Sprites = Each Sprites If s\mesh = sp Then s\view = vm Next End Function ;----------------------------------------------------------------------------------------------------- ; UpdateSprites() ;----------------------------------------------------------------------------------------------------- Function UpdateSprites(cam) For s.Sprites = Each Sprites If s\mesh <> 0 Then ;sprite view modes Select s\view Case 1 PointEntity s\mesh, cam, 0 Case 2 ;nothing needed Case 3 PointEntity s\mesh, cam, EntityRoll(cam, 1) Case 4 orgpt# = EntityPitch(s\mesh) PointEntity s\mesh, cam, EntityRoll(cam, 1) RotateEntity s\mesh, orgpt, EntityYaw(s\mesh), EntityRoll(s\mesh) End Select End If Next End Function ;----------------------------------------------------------------------------------------------------- ; FreeSprite() ;----------------------------------------------------------------------------------------------------- Function FreeSprite(sp) For s.Sprites = Each Sprites If s\mesh = sp Then FreeEntity sp Delete s End If Next End Function ;----------------------------------------------------------------------------------------------------- ; CreateSprite() ;----------------------------------------------------------------------------------------------------- Function CreateSprite(parent = 0) Return LoadSprite("", 0, parent) End Function
I've made a mesh-based version of the sprite commands.
To use them, copy everything from the line 'MESH-BASED SPRITE COMMANDS' into your program.
Two commands are different:
'UpdateSprites' should be called before RenderWorld, to enable the SpriteViewModes, and 'FreeSprite' should be used instead of FreeEntity.