Code archives/3D Graphics - Mesh/Sticky Shadow
This code has been declared by its author to be Public Domain code.
Download source code
| |||||
This function will allow you to let a shadow mesh 'hug' the underlying mesh. Make sure the landscape mesh is pickable, and that you know the surface handle (shadow_surf) and amount of vertexes (shadow_vertex_count) in the shadow mesh. shadowmesh in this example is the handle to the mesh that has to be deformed. This function picks down from worldypos 5, but you could lower or higher that if needed... have fun! | |||||
Function StickyShadow () For count = 0 To shadow_vertex_count -1 ; translate x and z pos of shadow vertex to world coordinates TFormPoint ( VertexX (shadow_surf, count), 5, VertexZ (shadow_surf, count), shadowmesh, 0) ; pick down from each vertex, get new world ypos from pickedy LinePick ( TFormedX() , 5, TFormedZ(), 0, -6, 0) ; translate back to shadow local coords TFormPoint ( PickedX(), PickedY()+ .03, PickedZ(), 0, shadowmesh) ; move current vertex there VertexCoords shadow_surf, count, VertexX (shadow_surf, count), TFormedY(), VertexZ (shadow_surf, count) Next End Function |
Comments
None.
Code Archives Forum