I was looking at the toolbbox and I found this code under misc I think. It had an orange ball and you could move the ball around and disrupt the fog.
I started wondering if it would work in 3D. So I changed the code (it was public domain after all) and made a VERY SIMPLE pic for the fog sprite.
I made a Greyscale BMP with essentially 2 colors... 0,0,0 and 11,11,11 the 11,11,11 pattern was just sprayed in a cloud shape. (I love PS8!)
then I ran it... looks good.
The original code had a FPS limiter but I kind of hacked that out. Try it!
; ID: 265
; Author: Vorderman
; Date: 2002-03-12 03:53:52
; Title: Carve through the fog
; Description: Wispy fog that a moving entity can carve a trail through
; MODIFIED by Ralph Dunn to see if 3D is possible
AppTitle "Wispy Fog"
Graphics3D 800,600,32,2
SetBuffer BackBuffer()
Color 255,255,255
SeedRnd MilliSecs()
HidePointer
;-------------- CONSTANTS ---------------------------
;Const gameFPS = 50 ;frame limiting
Const MAX_FOG = 100
Const SPREAD# = 10
Const GLOBAL_MUSH# = 1.0
;-------------- GLOBALS -----------------------------
Global CAM_yaw# = 0.0
Global CAM_zoom# = 20
Global NULLPIVOT = CreatePivot()
;-------------- TYPES -------------------------------
Type TYPE_FOG
Field x#,y#,z#
Field xs#,zs#
Field sprite
Field ax#,az#
Field mushiness#
End Type
Dim FOG.TYPE_FOG(MAX_FOG)
For a=1 To MAX_FOG
FOG.TYPE_FOG(a) = New TYPE_FOG
FOG(a)\sprite = LoadSprite("fog5.bmp",2) ;was 1
ScaleSprite FOG(a)\sprite,3,3
FOG(a)\x# = Rnd#(-SPREAD#,SPREAD#)
FOG(a)\y# = 1
FOG(a)\z# = Rnd#(-SPREAD#,SPREAD#)
FOG(a)\xs# = 0.0
FOG(a)\zs# = 0.0
FOG(a)\ax# = FOG(a)\x#
FOG(a)\az# = FOG(a)\z#
PositionEntity FOG(a)\sprite,FOG(a)\x#,FOG(a)\y#,FOG(a)\z#
FOG(a)\mushiness# = 0.25
Next
;-------------- ENTITIES ------------------------------
Global player = CreateSphere()
PositionEntity player,0,1.0,20
EntityColor player,255,100,0
Global camera=CreateCamera()
CameraViewport camera,0,0,800,600
;PositionEntity camera,0,20,-20
CameraClsColor camera,50,50,100
RotateEntity camera,45,0,0
AmbientLight 150,150,150
light1 = CreateLight(2)
PositionEntity light1,500,500,-500
;-------------- M A I N L O O P ---------------------------
While Not KeyHit(1)
mxs#=MouseXSpeed()/4
mys#=MouseYSpeed()/4
xa#=(xa#-mxs#)Mod 360
ya#=(ya#+mys#)Mod 360
MoveMouse GraphicsWidth()/2,GraphicsHeight()/2
RotateEntity camera,ya#,xa#,0
If KeyDown( 205 )=True Then TurnEntity camera,0,-.5,0
If KeyDown( 203 )=True Then TurnEntity camera,0,.5,0
If KeyDown( 208 )=True Then MoveEntity camera,0,0,-.5
If KeyDown( 200 )=True Then MoveEntity camera,0,0,.5
x#=EntityX(camera)
y#=EntityY(camera)
z#=EntityZ(camera)
; ---- HOW TO USE GRAVITY
;y#=y#-.4
; turned off gravity and took out loading a terrain plane stuff... flythrough for now!
PositionEntity camera,x#,y#,z#
;game logic loop
For frameLimit = 1 To frameTicks
;frame limiting
If frameLimit = frameTicks Then CaptureWorld
frameTime = frameTime + framePeriod
;mouse to move blob
MoveEntity player,(MouseXSpeed() / 10.0),0,-(MouseYSpeed() / 10.0)
MoveMouse 400,300
;update the fog
FUNC_process_fog()
;update game world logic
UpdateWorld
Next
;render
RenderWorld frameTween
;on-screen FPS counter
Color 255,255,255
Text 700,10,"FPS:"+FPS
Text 350,10,"WISPY FOG TEST"
Text 290,550,"USE MOUSE TO MOVE ORANGE BLOB"
Color 255,0,0
Text 295,562,"MOVE SLOWLY FOR BEST RESULTS"
;flip buffers
Flip
Wend
End
Function FUNC_process_fog()
For f.TYPE_FOG = Each TYPE_FOG
dist# = EntityDistance(f\sprite , player)
PositionEntity NULLPIVOT,f\ax#,1.0,f\az#
dist2# = EntityDistance(f\sprite , NULLPIVOT)
EntityAlpha f\sprite,((1.0/2.0)*(1.0-(dist2#/2.0)))
If ( dist# < 2.0 ) And (dist2# < 2.0)
PointEntity f\sprite , player
TurnEntity f\sprite,0,180,0
MoveEntity f\sprite ,0,0,(dist# / 5.0);0.1
f\x# = EntityX#(f\sprite)
f\z# = EntityZ#(f\sprite)
f\mushiness# = GLOBAL_MUSH#
Else
If (f\mushiness# =< 0.0)
PointEntity f\sprite,NULLPIVOT
dist# = EntityDistance(f\sprite , NULLPIVOT)
MoveEntity f\sprite,0,0,(dist#/30.0)
Else
f\mushiness# = f\mushiness - 0.1
EndIf
f\x# = EntityX#(f\sprite)
f\z# = EntityZ#(f\sprite)
EndIf
Next
End Function
I only added my graphic and movement commands... it is a flythrough for now but the one I did with terrainmap works well... Now to try it without TWEEN ;)
-RZ