1) I am not familiar with 3D programming, so I have a lot of questions, but the purebasic help-file does not explain a lot.
f.i.
the statement LightDirection(#Light, x, y, z) where x,y,z have values between -1 and 1 ???? what does the mean.
and what is the difference with the statement LightLookAt(#Light, x, y, z). etc....
Is there any comprehensive helpfile about the engine3D statements.
2)
In below example the mouse moves the CAMERA together with the LIGHT (black square) so the the top of the walls are highlighted
Anyone any idee why the longest horizontal wall is in the middel NOT affected by the light ?
Code: Select all
InitEngine3D()
InitSprite()
InitKeyboard()
InitMouse()
OpenWindow(0, 0, 0, 1600, 900, "Cube example", #PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 1600, 900, 0, 0, 0)
;CreateMaterial()
CreateTexture(0, 128, 128): StartDrawing(TextureOutput(0)): Box(0, 0, 128, 128, RGB(255, 255, 255)): StopDrawing(): glass = CreateMaterial(#PB_Any, TextureID(0))
CreateTexture(0, 128, 128): StartDrawing(TextureOutput(0)): Box(0, 0, 128, 128, RGB(255, 255, 255)): StopDrawing(): red = CreateMaterial(#PB_Any, TextureID(0))
CreateTexture(0, 128, 128): StartDrawing(TextureOutput(0)): Box(0, 0, 128, 128, RGB(255, 255, 255)): StopDrawing(): green = CreateMaterial(#PB_Any, TextureID(0))
CreateTexture(0, 128, 128): StartDrawing(TextureOutput(0)): Box(0, 0, 128, 128, RGB(255, 255, 255)): StopDrawing(): Blue = CreateMaterial(#PB_Any, TextureID(0))
CreateTexture(0, 128, 128): StartDrawing(TextureOutput(0)): Box(0, 0, 128, 128, RGB(255, 255, 255)): StopDrawing(): Black = CreateMaterial(#PB_Any, TextureID(0))
CreateTexture(0, 128, 128): StartDrawing(TextureOutput(0)): Box(0, 0, 128, 128, RGB(255, 255, 255)): StopDrawing(): White = CreateMaterial(#PB_Any, TextureID(0)): SetMaterialColor(White,#PB_Material_DiffuseColor,RGB(255,255,255))
CreateTexture(0, 128, 128): StartDrawing(TextureOutput(0)): Box(0, 0, 128, 128, RGB(255, 255, 255)): StopDrawing(): Yellow = CreateMaterial(#PB_Any, TextureID(0))
;camera
camX.f = 0: camY.f = 2645: camZ.f = 0
WH.f=250
Camera = CreateCamera(#PB_Any,0,0,100,100)
;lights
CreateLight(0, RGB(255, 255, 255), 0, WH, 0,#PB_Light_Point)
;CreateLight(1, RGB(255, 255, 255), 0, WH+80, 0,#PB_Light_Point)
;wall
cube_mesh = CreateCube(#PB_Any,1)
;Ground
CreateTexture(1, 128, 128): StartDrawing(TextureOutput(1)): Box(0, 0, 128, 128, RGB(180, 180, 180)): Box(0, 0, 64, 64, RGB(220, 220, 220)): Box(64, 64, 64, 64, RGB(120, 120, 120)): StopDrawing()
CreateMaterial(1, TextureID(1))
SetMaterialColor(1,#PB_Material_AmbientColor,RGB(0,0,255))
CreatePlane(1, 2980, 2107, 50, 50, 50, 50)
Ground = CreateEntity(#PB_Any, MeshID(1), MaterialID(1))
EntityRenderMode(Ground,#PB_Shadow_None )
;create wall
wallclr = white
;wallclr = red
Wall = CreateEntity(#PB_Any, MeshID(cube_mesh), MaterialID(wallclr), 0,WH/2,-210):ScaleEntity(Wall,400,WH,40)
Wall = CreateEntity(#PB_Any, MeshID(cube_mesh), MaterialID(wallclr), 0,WH/2,210):ScaleEntity(Wall,400,WH,40)
Wall = CreateEntity(#PB_Any, MeshID(cube_mesh), MaterialID(wallclr), -210,WH/2,0):ScaleEntity(Wall,400,WH,40): RotateEntity(Wall,0,90,0)
Wall = CreateEntity(#PB_Any, MeshID(cube_mesh), MaterialID(wallclr), 210,WH/2,0):ScaleEntity(Wall,400,WH,40): RotateEntity(Wall,0,90,0)
Wall = CreateEntity(#PB_Any, MeshID(cube_mesh), MaterialID(wallclr), 0,WH/2,0):ScaleEntity(Wall,2000,WH,40)
Wall = CreateEntity(#PB_Any, MeshID(cube_mesh), MaterialID(wallclr), 1010,WH/2,0):ScaleEntity(Wall,400,WH,40): RotateEntity(Wall,0,90,0)
Wall = CreateEntity(#PB_Any, MeshID(cube_mesh), MaterialID(wallclr), -1010,WH/2,0):ScaleEntity(Wall,400,WH,40): RotateEntity(Wall,0,90,0)
cam1.f = CreateEntity(#PB_Any, MeshID(cube_mesh), MaterialID(black), 0,5000,0):ScaleEntity(cam1,20,1,20) :RotateEntity(cam1,0,45,0)
Repeat
Repeat: Event = WindowEvent(): Until Event = 0
ExamineKeyboard()
ExamineMouse()
CamX -MouseDeltaX(): CamZ -MouseDeltaY(): camY -(MouseWheel()*20)
MoveCamera(Camera,camX,camY,camZ, #PB_Absolute)
CameraLookAt(Camera,CamX,0,CamZ-1)
MoveLight(0,camX,WH+120,camZ, #PB_Absolute)
LightLookAt(0,camX,0,camZ)
MoveEntity(cam1,camX,1000,camZ, #PB_Absolute)
RenderWorld(40)
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape)
ReleaseMouse(#True)
CloseWindow(0)