Main Menu

PlayBasicFX Screen Shot Updates

Started by kevin, February 16, 2007, 11:45:46 AM

Previous topic - Next topic

kevin

PlayBasicFX (from version 1.65 + above) Screen Shot Updates

    This thread is (will be) a collection of screen shots / demo tidbits during the development of PBFX.  Since PBFX now features  hardware 3D acceleration, the pics in this thread will mostly be old demos quickly updated to use some of the new benefits of 3D.

kevin


Z Rotater demo

   This pic of the z rotater example in the PB demo.  The main change are the textures were loaded as 3D images (load3DIMage) and then the front plan of the textures are drawn using the inkmode 1+32 (alpha 50).



kevin


Textured Cube Demo

   The texture is loaded as 3d image, than rendered with inkmode 32


kevin

 Texture Mapped Terrain


Read Here (login required)


kevin

#4
   UW3D ( 3D engine written in PlayBASIC )


   Read Here

kevin


Basic Sprite Draw Modes in PB1.67

    The replacement sprite engine is partly working again.  Sprites can be positioned,  scaled,  transparent, have handles, some draw modes (static, rotated, alpha, alha50, Alpha Addition) , vertex colours (in some draw modes)  and that's about it for the time being.



kevin


another pic.. all using alpha add

Ian Price

Those are two of the most beautiful PB screenies to date. Excellent work :)
I came. I saw. I played some Nintendo.

kevin

#8
Sprite Entities

    The following 4 pics represent a new feature in PB,   Sprite Entities.   What are they you ask ?   They're a new type of sprite that contains a mesh, each with it's own set of vertex and face definitions.  This allows a sprites to built in more complex shapes / structures than a traditional quad allows.   

   Bellow each sprite is set up with it's standard frame plus 10 each faces attached + offset from it.  So each sprite entity is basically the equivalent (in terms of drawing) of 11 old sprites.   You can have as many faces in the sprite as you like.   


  pic#1 = 1 sprites with  11 faces (22 polygons)
  pic#2 = 100 sprites with  11 faces (2200 polygons)

kevin


  More of the same but with alpha addtion.

  pic#3 = 250 sprites with  11 faces (5500 polygons)
  pic#4 = 500 sprites with  11 faces (11000 polygons)

kevin

#10
  This effect is made from 100 entity sprites, each with 250 faces (32*32 in size).   The faces are 2 pixels apart, so that they overlap each over, creating a laser effect when drawn using the spark particle image + alpha addition.

  That's 100*250*2 =50k triangles



kevin

#11
 Sprite Entities Cont

   Entities allow you to take the sprite and build more complex meshes from it.  In this tiny example, we're taking single frame sprite and adding a bunch of frames to form a ring of sprites out of 1 sprite .   These can then be rotated, scaled, moved and ultimately even collided with !

   The main benefit of entities is their batch friendly, so the entire sprite drawn, is only one draw call.  Where, normally you'd have to draw each face separately.
 



load3Dimage "animal.jpg",1
load3dimage "particle_white.bmp",2

; Create the foreground sprite + mesh around with it's mesh
CreateSprite 1
positionsprite 1,400,300
SpriteDrawmode 1,2
SpriteImage 1,1
centerspritehandle 1


SpriteVertexQuantity 1,8
SpriteFaceQuantity 1,8

PokeSpriteVertex 1, 4, 200,0,0
PokeSpriteVertex 1, 5, 300,0,0
PokeSpriteVertex 1, 6, 300,300,0
PokeSpriteVertex 1, 7, 200,300,0

PokeSpriteFaceVerts 1,1,4
PokeSpriteface 1,1,0,4,0,0,$ffff00
PokeSpriteface 1,1,1,5,1,0,$ffff00
PokeSpriteface 1,1,2,6,1,1,$ffffff
PokeSpriteface 1,1,3,7,0,1,$ff00ff


; deform the vertex 0 and 2 top left and bottom right
pokespritevertex 1,0,-30,-40,0
pokespritevertex 1,2,130,290,0

; POke Face 0 of this Sprite
PokeSpriteface 1,0,2,2,1.0,1.0,$ff00ff


; Create a bunch of entity sprites. These create rings of sprite frames
For lp=0 to 100
me= MakeParticleSprite(2,rnd(800),rnd(600),rndrange(10,20))
next

Do
Cls 0



drawallsprites

turnsprite 1,0.05
turnsprite me,0.15

scalesprite 2,1+cos(angle#)
print Fps()
angle#=angle#+1

 
Sync
loop 



Function MakeParticleSprite(ThisIMage,Xpos#,Ypos#,points)

ThisSprite=NewSprite(Xpos#,Ypos#,ThisIMage)

SpriteDRawMOde ThisSprite, 2+16

SpriteVertexQuantity thisSprite,(Points+1)*4
SpriteFaceQuantity thisSprite,(Points+1)

angleStep#=360.0/points
size=32

For lp=0 to points-1
angle#=wrapangle(angle#,anglestep#)
Radius#=100
SetVerts(ThisSprite,VertexOffset,Angle#,Radius#,Size,wrapangle(angle#,-45))
SetFace(ThisSprite,ThisFace,VertexOffset,RndRgb())
VertexOffset=VertexOffset+4
inc thisface
next



EndFUnction ThisSPrite


Function SetVerts(ThisSprite,VertexOffset,Angle#,Radius,Size,Rotation)

CenterX#=CosNewValue(0,angle#,Radius)
CenterY#=SinNewValue(0,angle#,Radius)


For lp=0 to 3
X#=CosNewValue(CenterX#,Rotation,Size)
Y#=SinNewValue(CenterY#,Rotation,Size)
PokeSpriteVertex ThisSprite,VertexOffset,X#,y#,z#
Rotation=wrapangle(Rotation,90)
inc VertexOffset
next

EndFunction


Function SetFace(ThisSprite,ThisFace,VertexOffset,ThisColour)
PokeSpriteFaceVerts ThisSprite,ThisFace,4
PokeSpriteface ThisSprite,ThisFace,0,VertexOffset+0,0,0,ThisColour
PokeSpriteface ThisSprite,ThisFace,1,VertexOffset+1,1,0,ThisColour
PokeSpriteface ThisSprite,ThisFace,2,VertexOffset+2,1,1,ThisColour
PokeSpriteface ThisSprite,ThisFace,3,VertexOffset+3,0,1,ThisColour
EndFunction









kevin

#12
Sprite Entities cont..

This one is mixture of scrolling back drop and sprite entity/particles.   The values on the top left of the display are FPS, Sprite Count & Face Count





load3dimage "D:\Play_Basic\PlayBasic\Projects\GFX\particle_white.bmp",2

loadimage "D:\Play_Basic\PlayBasic\Projects\GFX\Tree.jpg",1


Type tParticle
Sprite
X#
Y#
ScaleX#
ScaleY#
Time
MaxTime
Colour
EndType

Dim Parts(1) as tParticle
; setfps 60

Do

; Cls rgb(30,40,50)
Tileimage 1,Xpos,0,false
Xpos=mod(Xpos-1,GetIMageWidth(1))

SpriteCount=0
SpriteFaceCount=0
For lp=1 to GetArrayelements(Parts(),1)
if Parts(lp)
if Parts(lp).time<Parts(lp).Maxtime
Parts(lp).time=Parts(lp).time+1

x#=parts(lp).x
y#=parts(lp).y
sx#=parts(lp).Scalex+0.50
sy#=parts(lp).Scaley+0.50
Spr=parts(lp).Sprite
ScaleSpriteXY Spr,SX#,Sy#
TurnSprite Spr,0.25
;Angle#
parts(lp).Scalex=sx#
parts(lp).Scaley=sy#
inc SpriteCount
SpriteFaceCount=SpriteFaceCount+GetSpriteFaceQuantity(Spr)
else
DeleteParticles(lp)
endif


endif
next

DrawAllSprites

if Nexttime=0

x#=rnd(GetScreenWidth() )
y#=rnd(GetScreenHeight() )

; For lp=1 to 10
; AddParticles(2,x#,y#,rndrange(10,50))
; next

nexttime=2+rnd(3)
endif
dec nexttime




if Mousebutton()
x#=mousex()
y#=mousey()
AddParticles(2,x#,y#,rndrange(10,50))

endif


ink $ff0000
text 10,10,fps()
text 10,30,SpriteCount
text 10,50,SpriteFaceCount
Sync
loop


Function DeleteParticles(index)
DeleteSprite Parts(index).Sprite
Parts(Index)=null
EndFunction


Function AddParticles(ThisIMage,x#,y#,POints)
index=GetFreeCell(Parts())
Parts(index).x=x#
Parts(index).y=y#
Parts(index).scalex=1
Parts(index).scaley=1
Parts(index).colour=rndrgb()
Parts(index).Maxtime=50
Parts(index).time=0

Parts(index).Sprite=MakeParticleSprite(ThisIMage,X#,Y#,points)

EndFunction





Function MakeParticleSprite(ThisIMage,Xpos#,Ypos#,points)

ThisSprite=NewSprite(Xpos#,Ypos#,ThisIMage)

SpriteDRawMOde ThisSprite, 2+16

SpriteVertexQuantity thisSprite,(Points+1)*4
SpriteFaceQuantity thisSprite,(Points+1)

angleStep#=360.0/points
size=4
For lp=0 to points-1
angle#=wrapangle(angle#,anglestep#)
Radius#=rndrange#(1,50)
SetVerts(ThisSprite,VertexOffset,Angle#,Radius#,Size,wrapangle(angle#,-45))
SetFace(ThisSprite,ThisFace,VertexOffset,RndRgb())
VertexOffset=VertexOffset+4
inc thisface
next
EndFUnction ThisSPrite


Function SetVerts(ThisSprite,VertexOffset,Angle#,Radius,Size,Rotation)

CenterX#=CosNewValue(0,angle#,Radius)
CenterY#=SinNewValue(0,angle#,Radius)

For lp=0 to 3
X#=CosNewValue(CenterX#,Rotation,Size)
Y#=SinNewValue(CenterY#,Rotation,Size)
PokeSpriteVertex ThisSprite,VertexOffset,X#,y#,z#
Rotation=wrapangle(Rotation,90)
inc VertexOffset
next

EndFunction


Function SetFace(ThisSprite,ThisFace,VertexOffset,ThisColour)
PokeSpriteFaceVerts ThisSprite,ThisFace,4
PokeSpriteface ThisSprite,ThisFace,0,VertexOffset+0,0,0,ThisColour
PokeSpriteface ThisSprite,ThisFace,1,VertexOffset+1,1,0,ThisColour
PokeSpriteface ThisSprite,ThisFace,2,VertexOffset+2,1,1,ThisColour
PokeSpriteface ThisSprite,ThisFace,3,VertexOffset+3,0,1,ThisColour
EndFunction



stef

Hi!

This all sounds very very interesting!

Does this mean you can use those "faces" for independent particles
let's say 1 sprite with 1000 faces and you can place every face separatly on screen?

Or are the faces more for spriteanimation?


Greetings
stef

kevin

#14
QuoteDoes this mean you can use those "faces" for independent particles
let's say 1 sprite with 1000 faces and you can place every face separatly on screen?

  You can position the vertex are place you want, however their local to their sprites origin point (their offset from the sprites position)

However See Sprite Particles