Opposite of EntityAutoFade()
Blitz3D Forums/Blitz3D Programming/Opposite of EntityAutoFade()
| ||
I was thinking about making an LOD system by using the opposite of EntityAutoFade(entity, near, far) So, the entity will fade out when the camera gets closer to the mesh. cam = doh entity = the entity to manipulate near = the distance needed for the entity to be alpha 0 far = the distance needed for the entity to be alpha 1 Function EntityNAutoFade(cam, entity, near, far) r# = entitydistance(cam,entity) if r# >= near# and r# <= far then alphaval# = I have no idea how to do this. entityalpha entity, alphaval# endif End Function |
| ||
I think this works. |
| ||
Try this (tested):-Const C_FADEOUT_START# = 20.0 Const C_FADEOUT_END# = 4.0 Global G_user_not_rendered Function UpdateUserDistanceFade() ; Fades the user's character model (G_user_entity) if the camera target (G_camera_target) gets too close to the camera (G_camera). Local alpha# Local distance# = EntityDistance( G_camera, G_camera_target ) If distance# < C_FADEOUT_START# G_user_not_rendered = True alpha# = ( distance# - C_FADEOUT_END# ) / ( C_FADEOUT_START# - C_FADEOUT_END# ) If alpha# < 0.0 Then alpha# = 0.0 EntityAlpha( G_user_entity, alpha# );SetRecursiveEntityAlpha( G_user_entity, alpha# ) ElseIf G_user_not_rendered G_user_not_rendered = False EntityAlpha( G_user_entity, 1.0 );SetRecursiveEntityAlpha( G_user_entity, 1.0 ) EndIf End Function |
| ||
Basically how it works: |