Z Depth Perspective For Sprites
Here's a simpler variation of the classic 'CustomSceneDepth' example you'll find the example pack under Demos. It shows how you can project 3D space (none rotated) into 2D screen coordinates. From there it's just matter of scaling our media to fit the required size. In this version I've used a sprite, but you can use Polygons (TexturedQuads), Shapes, Images. whatever..
Requires PlayBasic V1.64L
[pbcode]
Setfps 60
Size=256
Img=NewfXimage(size,size)
RenderPhongImage img,size/2,size/2,$ff0000,256,2
ProjectionX#=400
ProjectionY#=400
; objects Width and Height and depth in the scene
ObjectWidth=size
ObjectHeight=size
ObjectDepth=5000
; use a spritge to represent this object on screen
Spr=NewSprite(0,0,img)
SpriteDrawMode Spr,2
AutoCenterSpriteHandle spr,true
Do
; Clear the screen
Cls
; project the obejcts screenwidth and height at this depth
ScreenWidth#=(ObjectWidth*ProjectionX#)/ObjectDepth
ScreenHeight#=(ObjectHeight*ProjectionY#)/ObjectDepth
ScaleX#=ScreenWidth#/GetImageWidth(img)
ScaleY#=ScreenHeight#/GetImageHeight(img)
positionsprite spr,GetScreenWidth()/2,GetScreenHeight()/2
ScaleSpriteXY spr,scaleX#,scaley#
SpriteTint Spr, rgbdepthcue($ffffff,0,Objectdepth,500,2500)
drawsprite Spr
ObjectDepth=wrapvalue(ObjectDepth-10,50,2500)
Sync
loop
[/pbcode]
Related To:
2.5D Rugby Source (http://www.underwaredesign.com/forums/index.php?topic=2980.0)
Manual Projection/Scene Perspective (http://www.underwaredesign.com/forums/index.php?topic=3279.0)
Mip Mapped Image Zoomer (http://www.underwaredesign.com/forums/index.php?topic=3617.0)