j'ai un petit probleme d'eclairage. Ou est ce que ca se passe ?
2eme question : comment mapper chaque face du cube par une texture differente ?
thx
Code : Tout sélectionner
EnableExplicit
;Scene
Global Camera, Light
Global xx.f=20
Global yy.f=24.8
Global zz.f=31
; Returns a random sign {-1, 1}
Macro RandomSign()
( Random(1)*2-1 )
EndMacro
;Summary
Declare GameLoad()
Declare RenderGame3D()
GameLoad()
Procedure GameLoad()
Protected Window, n
If InitEngine3D() And InitKeyboard() And InitSprite() And InitMouse() And InitSound()
Window = OpenWindow(#PB_Any, 0, 0, 0, 0, "", #PB_Window_Maximize | #PB_Window_BorderLess)
SetWindowColor(Window, 0)
;-[Screen]
OpenWindowedScreen(WindowID(Window),0, 0, WindowWidth(Window) , WindowHeight(Window))
KeyboardMode(#PB_Keyboard_International)
;-[2D]
;-[3D]
Add3DArchive(#PB_Compiler_Home + "Examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
;-Camera
Camera = CreateCamera(#PB_Any, 0, 0, 100, 100)
CameraBackColor(Camera, RGB(0, 0, 0))
MoveCamera(Camera, 0, 0, -100)
CameraLookAt(Camera, 0, 0, 0)
;-Light
Light = CreateLight(#PB_Any, RGB(255, 255, 255), 0, 1000, 0, #PB_Light_Point)
SetLightColor(Light, #PB_Light_SpecularColor, RGB(255, 255, 255))
SetLightColor(Light, #PB_Light_DiffuseColor, RGB(255, 255, 255))
;Création de 5000 cubes
CreateMaterial(0, TextureID(LoadTexture(-1, "glass_Dirt.png")))
MaterialBlendingMode(0, #PB_Material_AlphaBlend)
SetMaterialColor(0, #PB_Material_SpecularColor, RGB(255,255,255))
CreateEntity(0, MeshID(CreateCube(-1, 20)), MaterialID(0))
RotateEntity(0,20,17.4,31.8)
; For n = 1 To 50
; MoveEntity(CopyEntity(0, -1), 100 * RandomSign(), 100 * RandomSign(), Random(10) * RandomSign())
; Next
;-Loop
While #True
Repeat : Until WindowEvent() = 0
RotateEntity(0,xx,yy,zz)
xx+1.12
yy+1.458
zz+1.5
FlipBuffers()
RenderGame3D()
RenderWorld()
Wend
Else
EndIf
EndProcedure
Procedure RenderGame3D()
;RotateCamera(Camera, 0.1, 0.1, 0.1, #PB_Relative)
If ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
End
EndIf
EndIf
If ExamineMouse()
EndIf
EndProcedure