Is using the same variable a bad method?Olli wrote:you erase indirectly cube mesh identifier (by reuse "mesh" variable)
I use twice the entity variable in this code to create a plane and a cube.
Code: Select all
EnableExplicit
Global window, event, camera, Entity
InitEngine3D(#PB_Engine3D_DebugLog)
InitKeyboard()
InitSprite()
window = OpenWindow(#PB_Any, 0, 0, 1024, 768, "Test Shadow")
OpenWindowedScreen(WindowID(window),0,0,1024,768)
; Light
CreateLight(#PB_Any,RGB(255, 218, 185), 500, 1000, -1000)
WorldShadows(#PB_Shadow_Additive)
; Camera
camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
MoveCamera(camera, 0, 5, 20)
CameraLookAt(camera, 0, 0, 0)
Entity = CreateEntity(-1, MeshID(CreatePlane(-1, 10, 10, 1, 1, 1, 1)), #PB_Material_None)
CreateEntityBody(Entity, #PB_Entity_StaticBody, 0, 0.1, 0.1)
Entity = CreateEntity(-1, MeshID(CreateCube(-1, 2)), #PB_Material_None, 0, 5, 0)
CreateEntityBody(Entity, #PB_Entity_BoxBody, 1, 0.1, 0.1)
; Render
While #True
event = WindowEvent()
ExamineKeyboard()
If event = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
Break
EndIf
RenderWorld()
FlipBuffers()
Wend