SpriteControl

(Last updated on 07 March 2004)

IMPORTANT NOTES ABOUT THE NEW VERSION

This new release of SpriteControl as had a significant amount of changes and modifications applied.
For starters, I am now using SkidRacers excellent routines to achieve 'pixel-perfect' sprites.
They really do look like normal images now.

Changed

LoadAnimImage3D() now has an extra framesY parameter to allow loading of images where the animation is laid out in both colums AND rows.
The first frame number of the animation has changed to 1 (instead of 0).

ModifyText3D no longer needs to know the texture of the sprite.
The handle/hotspot of loaded sprites is now top/left by default. See the new MidHandle3D command
DrawImage3D handles animations with a new 'frame' parameter
The global variables in SpriteControl are now called:

spritecamera - handle of the main camera created by the SpriteGraphics3D command
spritepivot - handle of the sprite pivot created by the SpriteGraphics3D command

Removed

SpritePivotZoom. See CameraZoom3D
CreateSpriteCamera. Use CreateSpritePivot instead

New Commands

SpriteGraphics3D - for easy setting up of the 3d display
EndGraphics3D - free up sprites, textures, brushes, and close the screen in one call
CameraZoom3D - zoom the main camera and update the sprite pivot simultaneously
MidHandle3D - centers the quads handle
ImageToSprite - creates a sprite from an already loaded 2d image
FreeImage3D - Cleans up an exiting sprite
GetSpriteTexture - returns the handle of the sprites texture
ImagesOverlap3D() - test if two sprites are overlapping

 

By Syntax Error - config2000 AT hotmail.com

A set of 26 commands and functions for manipulating 3d quad sprites just like you would with 2D images.

Key features:

> Display 'pixel-perfect' 3d sprites just like 2d images *THANKS TO SKIDRACER*
> Use 2D screen coordinates for positioning
> Resize in pixel dimensions
> Rotate / Fade / Re-color /Alpha
> Works with any 3D graphics resolution
> Any camera zoom ratio >=1
> Easy to load and position the sprites
> Functions & commands similar in operation to 2d counterparts

 

Command List:

SpriteGraphics3D width,height[,depth][,viewmode][,pivotdistance#]
EndGraphics3D
piv=CreateSpritePivot(maincamera[,distance#])
CameraZoom3D camera,zoomratio#
sprite=CreateImage3D([width][,height][,parent])
sprite=LoadImage3D(file$[,flags][,parent])
sprite=LoadAnimImage3D(file$,frames[,flags][,parent])
sprite=GrabImage3D(x,y,w,h[,parent])
sprite=CopyImage3D(existingsprite)
sprite=Text3D(x,y,text$[,flags][,parent])
ModifyText3D sprite,x,y,text$[,flags]
DrawImage3D sprite,x,y[,frame][,z#]
ResizeImage3D sprite,width,height
FlipImage3D sprite[,horizontalflag][,verticalflag]
RotateImage3D sprite,angle#
HandleImage3D sprite,xoffset#,yoffset#
MidHandle3D sprite
hx#=ImageXHandle3D(sprite)
hy#=ImageYHandle3D(sprite)
w=ImageWidth3D(sprite)
h=ImageHeight3D(sprite)
result=ImagesOverlap3D(sprite1,sprite2[,overlap1][,overlap2])
MaskImage3D sprite,red,green,blue[,totalframes]
newsprite=ImageToSprite(existingimage)
FreeImage3D sprite
texture=GetSpriteTexture(sprite)

 


Download

The zip Includes plenty of examples demonstrating most the commands/functions.
Documentation is also included.

Download SpriteControl


Documentation

You can read the online docs here. These are also inlcuded in the download.

 

SpriteControl Docs Pak:

By installing the Docs Pak you will have instant help for each of the SpriteControl functions.
Plus, all of the commands are recognised by Blitz ( highlighted/capitalised).
Also, the F1 help function works as well!

** Note 1: You need the latest version of Blitz3D with the userlibs feature for this to work.

Refer to the installation notes in the Docs Pak folder which is included in the zip


Example Usage:

Include "Sprite Control.bb" ; the include
SpriteGraphics3D width,height ; set 3d display + camera + sprite pivot
   
myimage=LoadImage3D("example.bmp") ; load example image
   
Repeat  
; .. do 3d stuff  
DrawImage3D myimage,MouseX(),MouseY() ; draw the sprite at mouse coordinates
RenderWorld ; render the 3d world
; .. draw 2d stuff here  
Flip ; flip the buffers
Until KeyHit(1) ; until ESC key is pressed
   
End ; end program