Is this what you guys want? This is a material script that will cast a shadow through any alpha on materials.
Now, the code to run and display the script.
Don't Forget to set the paths for the script and texture.
Code: Select all
;PRESS Escape to exit
#CameraSpeed = 1
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
ExamineDesktops()
DeskWid=DesktopWidth(0)
DeskHei=DesktopHeight(0)
Add3DArchive("C:\Script", #PB_3DArchive_FileSystem);####SET THE PATH TO YOUR MATERIAL SCRIPT.
Add3DArchive("C:\Texture", #PB_3DArchive_FileSystem);####SET THE PATH TO YOUR TEXTURE THAT THE MATERIAL SCRIPT USES.
If OpenWindow(0, 0, 0, DeskWid, DeskHei, "Alpha to Shadow", #PB_Window_ScreenCentered)
If OpenWindowedScreen(WindowID(0), 0, 0, DeskWid, DeskHei, 0, 0, 0)
Parse3DScripts()
GetScriptMaterial(BoxMaterial, "Transparent")
BoxMesh=CreateCube(#PB_Any,40)
BoxEntity=CreateEntity(#PB_Any,MeshID(BoxMesh),MaterialID(BoxMaterial),0,-15,0)
PlaneTexture=CreateTexture(#PB_Any,32,32)
StartDrawing(TextureOutput(PlaneTexture))
Box(0,0,32,32,RGB(0,0,255))
StopDrawing()
PlaneMaterial=CreateMaterial(#PB_Any, TextureID(PlaneTexture))
PlaneMesh=CreatePlane(#PB_Any,10000,10000,10,10,10,10)
PlaneEntity=CreateEntity(#PB_Any,MeshID(PlaneMesh),MaterialID(PlaneMaterial),0,-40,0)
EntityRenderMode(PlaneEntity,0)
CreateCamera(0, 0, 0, 100, 100)
MoveCamera(0, -50, 0, 100, #PB_Absolute)
CameraLookAt(0,0,0,0)
CreateLight(0,RGB(255,255,255),500,500,200)
WorldShadows(#PB_Shadow_TextureAdditive, 0, RGB(127, 127, 127), 4096)
Repeat
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera(0, KeyX, 0, KeyY)
RenderWorld()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
EndIf
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf
End
I hope this took care of your problems. If not let me know.