Code archives/3D Graphics - Effects/Easy Shadows (flat surfaces only)

This code has been declared by its author to be Public Domain code.

Download source code

Easy Shadows (flat surfaces only) by danjamwoo
(Posted 22 years ago)
This is the easiest way to get decent looking shadows. The only problem is that they only work on a single flat surface.
; lazy mans shadows ;
;      by tank      ;
Graphics3D 640,480,32,2
SetBuffer BackBuffer()

campiv=CreatePivot()
camera=CreateCamera(campiv)
MoveEntity camera,0,5,-10
TurnEntity camera,25,0,0

cone=CreateCone()
MoveEntity cone,0,5,0

shadow=CreateCone()
EntityFX shadow,1
EntityColor shadow,10,10,10
ScaleEntity shadow,1,0.001,1
MoveEntity shadow,0,0.11,0
EntityAlpha shadow,0.5

platform=CreateCube()
ScaleEntity platform,5,0.1,5
EntityColor platform,100,100,100

light=CreateLight()
MoveEntity light,0,20,0
TurnEntity light,90,90,0

scale#=1.0

; M A I N  L O O P ;
While Not KeyHit(1)
		
	TurnEntity campiv,0,0.1,0
		
	RotateMesh cone,1,1,0
	RotateMesh shadow,1,1,0
	
	If KeyDown(200) Then scale# = scale# + 0.01
	If KeyDown(208) Then scale# = scale# - 0.01
	ScaleEntity cone, scale#, scale#, scale#
	ScaleEntity shadow, scale#+(scale#*0.4), 0.001, scale#+(scale#*0.4)
		
	UpdateWorld
	RenderWorld
	
	Text 10,10,"Use the UP ARROW and DOWN ARROW keys to change the scale of the cone."
	
	Flip
	
Wend

Comments

Clarks
(Posted 22 years ago)
thats pretty neat

puki
(Posted 22 years ago)
Nice shadow thingy

>'The only problem is that they only work on a single flat surface'

Still useful.

Devils Child
(Posted 21 years ago)
waaah, rubish...( sry:( )

but if you wanna have a stencil shdaow system, just go into my worklogs(signature or click onto my name)!

Naughty Alien
(Posted 21 years ago)
you said you will make it faster (I try it and its still not for real use)...so, I hope it will be updated soon (I'm talking about stencil shadows)

Devils Child
(Posted 21 years ago)
well, i dont know wether i can make it faster... i cannot promise you that it will be faster...

fireshadow4126
(Posted 18 years ago)
thanks

very simple, but effective for my purposes, considering that the game that I'm making is mostly inside a labyrinth, so it's going to be flat

Malice
(Posted 18 years ago)
Nice and fast, Shame if you try using more complex shapes, or have 'AddMesh' though.

Code Archives Forum