News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

3D Fire Lines

Started by kevin, April 17, 2022, 09:48:42 AM

Previous topic - Next topic

kevin

  3D Fire Lines #3 (PlayBASIC Edition)

   I originally wrote this demo 20 years ago in #DarkBASIC so it's fitting today to bring to #PlayBASIC in full glory :)

   The code is basically the same; visually i've added alpha addition to the lines and a globe to the line head with an alpha multiply pass to fade previous pixel date away.

    I did tweak the line logic also so that rather than randomly jump between directions it'll interpolate between them.  Giving a more curved motion the lines..

     In this edition we've added smoother motion of the fire lines with alpha addition fo  the rendering a circle to show the head of the line as well as a pass of alpha multiply.  


     Key Commands used:  InkMode - BlitIMage  - Line - Circle - Alpha Addition


PlayBASIC Code: [Select]
; PROJECT : 3D Fire Lines - DARK BASIC port - Version 03 - Save Animation
; AUTHOR : Kev Picone - http://playbasic.com
; CREATED : 15/04/2022
; EDITED : 17/04/2022
; ---------------------------------------------------------------------

` *=---------------------------------------------------------------------=*
` *=---------------------------------------------------------------------=*
` *=-------------------->> PORTED FROM DARK BASIC <<---------------------=*
` *=---------------------------------------------------------------------=*
` *=---------------------------------------------------------------------=*


` This is the final version of the effect. In this edition we've
` added smoother motion of the fire lines with alpha addition for
` the rendering a circle to show the head of the line as well as
` a pass of alpha multiply.

` *=---------------------------------------------------------------------=*
`
` >> 3D Fire Lines V0.03 <<
`
` By Kevin Picone
`
` Original: 24,May,2001
`
` PlayBASIC Update: 15,April,2022
`
` (c) Copyright 2001/2022, By Kevin Picone, All Rights Reserved.
`
` *=---------------------------------------------------------------------=*
` www.Underwaredesign.com www.PlayBASIC.com
` *=---------------------------------------------------------------------=*
`
` So WHAT does this do ?:
` =======================
`
` The Idea for this effect comes from both a demo "Jn_omega" wrote and a
` open gl demo I saw a while back. Figured, it might make an interesting
` snippet, so here it is.
`
` This demo renders a group of glowing (for want of a better word) lines
` moving in 3D space. While DB's line speed does put the breaks on this
` effect, it's 'not' entirely to blame, as the update routine is shifting
` data it really doesn't need too.. but i'm not fussed :)
`
`
` Bugs:
` =====
`
` One thing that is missing from this demo and perhaps those will a keen
` eye would have spotted it, is the lack of zbuffering in the rendering,
` granted it's fairly hard to tell with only a hand full of lines, but
` it is missing none the less.
`
`
` Release Info:
` =============
`
` Your welcome to use this code freely in your own projects, a credit
` and perhaps a link would be nice. Thank You.
`
`
` Cya,
` Kevin Picone
`
` *=---------------------------------------------------------------------=*


#include "blitimage"

` Define Useful Constants (just makes the code more user friendly/readable)


constant Mode_3d=ac(1)
constant Mode_2d=ac(1)



` Define Program Constants.

ScreenWidth =GetScreenWidth()
ScreenHeight =GetScreenHeight()
ScreenBitDepth=16

Title$ = "3D Fire Lines"
Version$ = "V0.03"

titlescreen Title$+" "+Version$



` Setup The Fire Line Array and Define How many LINES we want, and how
` LONG they should be.

Numb_of_FireLines =200
Numb_of_FireLinesSegMents =200


` Select a mode to run the demo in 3D or 2D are possible

FireLines_status=Mode_3D
` FireLines_status=MODE_2D



gosub _Init_Fire_lines



` *=----------------------------------------------------------------=*
` Main Loop
` *=----------------------------------------------------------------=*

Screen=NewFXImage( ScreenWidth, ScreenHeight)

do

rendertoimage Screen


gosub _Handle_Fire_Lines


inkmode 1+64
if FireLines_status=MOde_3D

` Change Angles for 3D Fire lines
anglex#=wrapangle(anglex#,0)
angley#=wrapangle(angley#,0.2)
anglez#=wrapangle(anglez#,0.15)

gosub _Render_3D_Fire_Lines

else
gosub _Render_2D_Fire_Lines
endif
inkmode 1

rendertoscreen


BlitImageAlphaPostMultColour(Screen,0,0,RGB(200,190,190))

sync
loop Spacekey()=true



Login required to view complete source code



 Demo

     



 Code Overview

   



    Music: www.bensound.com

   #learntocode #howtocode #basic


   


[ Links ]


    3D Fire Lines - Morphing Into Cube Version - Nice Bugs
    Download PlayBASIC Free Edition
    Script On Pastebin:
    DarkBASIC Source Codes 


 
Download Source Code


      Download all three examples bellow.