Pete,
(1) I broke my level into small sections
- I would suggest you do the same and ensure the sections where the cars can cast shadows (the track and tracksides) are broken down into low polygon sections - the less polygons the better, certainly not thousands in each section as a rough guide. This will also depend upon the power of the users pc's minimum spec you are aiming for I guess.
I load these in, and then set up a type so that I know where my character's camera is - you too may only need to show shadows around your main cars camera - as follows:
Path000 would be your staring grid
Path001 would be the next bit of track afterwards.
Path002 would be the third section of track the cars will come to
Part 1 of my set up is something like this
Type LevelShadow
Field entity
Field On
End Type
b.LevelShadow = New LevelShadow
b\entity = path000
b\on = 1 ; the shadow receiver for this section of track is set to on - it will dsiplay a shadow
b.LevelShadow = New LevelShadow
b\entity = path001
b\on = 2 ; the shadow receiver for this section of track is set to on - it will display a shadow
;the '2' part of this is so I can have a previous piece of path with a shadow still able to fall on it if I go back - retracing my steps - you won't need this I don't think.
b.LevelShadow = New LevelShadow
b\entity = path002
b\on = 0 ; the shadow receiver for this section of track is switched off - it wont display a shadow
(2) I switch the shadow receviers on if they are ready to be turned on:
Part 2 of my set up is something like this
;switch shadows to be received if they are set ON=True/1
For b.Levelshadow = Each LevelShadow
If b\on= 1
Receive_Shadow(b\entity) ; If not already shadow receiver then - make this entity a receiver
End If
Next
(3) Then I check for the character (this will be each of your cars I guess) to see if he is stood on any particular part of the track, and if so which part.
Now in my main loop I monitor which area my character is stood on it, and turn it on so it can receive a shadow.
; Now in the main loop, use something like this routine - entHit has the name of the section of my level the character is stood on
; defind by
entHit = EntityCollided(playerentityname,ground_collision_type)
If entHit <> oldenthit Then
; don't keep setting the same receivers or it will grind to a halt
; Oldhit contains the entity of the path the character is stood on
For b.Levelshadow = Each LevelShadow
If (b\on=1) And (entHit <> oldenthit)
delete_shadow_receiver(b\entity)
b\on=0
End If
If (b\on >0) And (entHit <> oldenthit)
b\on=b\on-1
End If
If b\on= 0 And entHit = b\entity Then
Receive_Shadow(entHit) ; If not already shadow receiver then - make this entity a receiver
oldenthit=entHit
b\on= 2
End If
Next
oldenthit=entHit
End If
You may have to do this for all your cars so it would be best to set up a function with this last bit in it and send each entHit after each car is tested for what is under it.
What should happen is only those sections which your cars touch will have shadows receivers on them, this means that you will be testing a very much smaller section of your track every loop, so you should see a huge jump in fps - er I hope! lol.
Let me know how you get on. Email me or msn me(peter@...) or skype me (petermcaddock) if you want to chat live.
Best regards,
IPete2.