BasicGL for Blitz

Blitz3D Forums/Blitz3D Programming/BasicGL for Blitz

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Needs a proper shadow system thought ("sswifty"?)

You have to parent each surface individually to the shadow:
;=====================================================
;                 			Basic GL For BlitzBasic © 2004                                          										               						      
;	 	Creator: Albert Khakimov (arkon) - arkon@...           					      
;  		Sample: Shadow                                                								      
;	  	Version: 0.1                                              									
;  		Author:  Korolyov Sergey (ventru) - ventrual@...        						
; 	 	Date: 13.11.04                                              									                        										
;=====================================================

Include "../../Constants.bb"
Include "../../keycodes.bb"


Global Camera, Light, Plane
Global Actor, Actor_Weapon, Actor_Shadow

;3d Graphics initialization
;gInitGraphics(640, 480, 32, 0, 0)
gInitGraphics(1024, 768, 16, 0, 0)
;Adjust buffer options
gBufferOptions 1, 1, 1, 0, 0, 0, 0, 0, 0   

gCreateText 1, 18, "Press Left or Right key to rotate actor", 0, 0, 0, 0

;S C E N E
;------------------------------------------------------------------------
gAmbientColor 1, 1, 1
;Methods of scene sorting And culling
gSceneSorting 1
gSceneCulling 3
;Create Camera
Camera = gDefaultCamera()
gSetPosition Camera, 60, 30, 40
gSetDepthOfView Camera, 200
;Create Light
Light = gCreateLight(0)
gSetPosition Light, 50, 100, 50
;Crea Plane
Plane = gCreatePlane(200, 200, 0)
gSetAbsDir Plane, 0, 1, 0
gSetPosition Plane, 0, -24, 0
gPlaneTiles Plane, 5, 5
gLoadObjectTexture Plane, "../../media/back1.jpg"
gObjTextureMode Plane, 1  

;Crea Plane
Plane2 = gCreatePlane(200, 200, 0)
gSetAbsDir Plane2, 0, 0, 1
gSetPosition Plane2, 0, 0, -22
gPlaneTiles Plane2, 5, 5
gLoadObjectTexture Plane2, "../../media/back1.jpg"
gObjTextureMode Plane2, 1  

;Crea Plane
Plane3 = gCreatePlane(200, 200, 0)
gSetAbsDir Plane3, 1, 0, 0
gSetPosition Plane3, -22, 0, 0
gPlaneTiles Plane3, 5, 5
gLoadObjectTexture Plane3, "../../media/back1.jpg"
gObjTextureMode Plane3, 1  

;A C T O R S
;------------------------------------------------------------------------
;Load Actor
Actor = gCreateActor("../../media/md2/tris.md2", 0)
gSetAbsDir Actor, 0, 1, 0
gSetAbsUp Actor, 0, 0, -1
gLoadObjectTexture Actor, "../../media/md2/skin.jpg"
gAnimationInterval Actor, 200
gAnimationMode Actor, 2
gSetTargetObject Camera, Actor
;Load Actor Weapon
Actor_Weapon = gCreateActor("../../media/md2/weapon.md2", Actor)
gLoadObjectTexture Actor_Weapon, "../../media/md2/weapon.jpg"
gSetAnimations Actor_Weapon, Actor
gAnimationInterval Actor_Weapon, 200
gSyncronize Actor_Weapon, Actor
;Create Actor Shadow
Actor_Shadow = gCreateShadowVolume(0)
gAddShadowCaster Actor_Shadow, Actor, 0
gAddShadowCaster Actor_Shadow, Actor_Weapon, 0
gAddShadowLight Actor_Shadow, Light, 0
gShadowMode Actor_Shadow, 0
gShadowColor Actor_Shadow, 0, 0, 0, 0.5
gShadowOptions Actor_Shadow, 0, 1, 0, 0
gSetParent Plane, Actor_Shadow  
gSetParent Plane2, Actor_Shadow  
gSetParent Plane3, Actor_Shadow 

While gKeyHit(KEY_ESCAPE) = 0 And gProgress() = 1

	If gKeyDown(KEY_LEFT) Then gRoll Actor, -1
	If gKeyDown(KEY_RIGHT) Then gRoll Actor, 1      
 
	newTime# = gGetNewTime()
	gSetPosition Light, Sin(newTime#) + 10, 100, 40   

Wend

gCloseGraphics()

This works - but, but when I added a second actor (not shown here), I couldn't cast shadows off both of them together - perhaps because of the 'parenting' of planes and shadows.