News:

Function Finder  Find all the functions within source code files

Main Menu

Sparkler

Started by kevin, September 04, 2009, 02:42:32 AM

Previous topic - Next topic

kevin

  Sparkler

   This little effect is a combination vertex rotation a few other recent demo effects..

PlayBASIC Code: [Select]
   setfps 50

SceneProjectionX# =300
SceneProjectionY# =300

NumberOfVertex =1000

// Size of a single vertex (XYZ)
SrcVertSize =12
DestVertSize =20


// Array to hold the none rotated vertex
Dim VertexFrame1#(2 ,(NumberOfVertex+1))
Dim VertexFrame2#(2 ,(NumberOfVertex+1))

// Array to hold the rotated vertex
Dim RotatedVertex#(4,(NumberOfVertex+1))


for t= 0 To NumberOfVertex
xd = Rndrange(-90,90)
x0 = (Cos(xd) * 10) * (Cos(t) * 10)
y0 = (Cos(xd) * 10) * (Sin(t) * 10)
z0 = Sin(xd) * 100
VertexFrame2#(0,t)=x0*6
VertexFrame2#(1,t)=y0*6
VertexFrame2#(2,t)=z0*6
Next


do

width=245
height=256
scale=100
BackdropColour=rndrgb()
BackdropIMage=Make_Background_Block(Width,Height,Scale,BackdropColour)



// Size of the vertex cube
ObjectSizeX =500
ObjectSizeY =500
ObjectSizeZ =500




// Objects Base X/Y position
basex#=0
basey#=0
basez#=800

// Precalc the Depth que shade array to shade the dots based upon the dots depth from the viewer
Dim ShadeBufferBuffer(20000)
NumberOfVertexdepth#=3000
scaler#=100/NumberOfVertexdepth#
; col=rndrgb()
col=BackdropColour
col=rgbalphamult(col,$505050)
For lp=0 To NumberOfVertexdepth#
ShadeBufferBuffer(lp)=RGBFade(col,(NumberOfVertexdepth#-lp)*scaler#)
Next


Sw=GetScreenWidth()
Sh=GetScreenHeight()


Screen=NewFXimage(sw,sh)
rendertoimage screen

// Create a camera to draw the scene (with depth ordering)
CreateCamera 1

// Turn CLS off in the camera. This allows us to perform an Asycn CLS while the
// vertex are being rotataed
CameraCls 1,off

rendertoscreen

// --------------------------------------------------------------------------------
// Main loop ---------------------------------------------------------------------
// --------------------------------------------------------------------------------
StartingTime=Timer()

Do

// Tell PB to capture draw commands to the Scene buffer
CaptureToScene

// Clear the scene at start of the frame, so there's no left over junk in there from a previous frame
ClsScene

capturedepth 8000

TimePast=Timer()-StartingTime


PixelsPerTick#=(GetImageWidth(Backdropimage)/4)/1000.0
Xpos=PixelsPerTick#*TimePast
customtileimage backdropimage,Xpos,0,FALSE

DegreesPerTick#=(1.01*60)/1000.0
ax#=WrapAngle(DegreesPerTick#*TimePast,0)

DegreesPerTick#=(0.42*60)/1000.0
ay#=WrapAngle(DegreesPerTick#*TimePast,0)

DegreesPerTick#=(0.9*60)/1000.0
az#=WrapAngle(DegreesPerTick#*TimePast,0)


// Get Address of Array source vertex
SrcAddress =GetArrayPtr(VertexFrame2#())+PBArraystruct_Size

// Get address of rotated vertex (none projected)
DestAddress =GetArrayPtr(RotatedVertex#())+PBArraystruct_Size

// Rotated the vertex list
RotateVertexListXYZ SrcAddress,SrcVertSize,DestAddress,DestVertSize,baseX#,basey#,baseZ#,ax#,ay#,az#,NumberOfVertex

xc=sw/2
yc=sh/2
inkmode 1+64

// Draw the list of camera. So they can drawn in order when the
For vert=0 to NumberOfVertex-1
z#=RotatedVertex#(2,Vert)
If z#>10
Capturedepth z#*2
X#=xc+(RotatedVertex#(0,Vert)*SceneProjectionx#)/z#
Y#=yc+(RotatedVertex#(1,Vert)*SceneProjectiony#)/z#
linec xc,yc,x#,y#,ShadeBufferBuffer(z#)
endif
next
inkmode 1

// draw the scene
DrawCamera 1


drawimage screen,0,0,false
; drawrotatedimage Screen,0,0,0,0.5,1,0,0,false+8

SetCursor 0,0
speed#=10
Login required to view complete source code