; ; ------------------------------------------------------------ ; ; PureBasic - Reflection ; ; (c) Fantaisie Software ; ; ------------------------------------------------------------ ; ; Используйте стрелки клавиатуры для перемещения / прокрутки плана. ; Используйте F12 для переключения между каркасным и текстурированным режимом. ; #PB_UNIT_Y=1 IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb" Define.f MouseX,Mousey, a, ap, dp, co, si Procedure.f POM(v.f) ProcedureReturn (Random(v*1000)-v*500)/500 EndProcedure Procedure SetupMaterial(n, Filename$, scale.f=1) LoadTexture(n, Filename$) CreateMaterial(n,TextureID(n)) ScaleMaterial(n,0.5/scale,1/scale) EndProcedure If InitEngine3D() InitSprite() InitKeyboard() InitMouse() If Screen3DRequester() Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem) Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/desert.zip", #PB_3DArchive_Zip) Parse3DScripts() SkyBox("desert07.jpg") CreateCamera(0, 0, 0, 100, 100) MoveCamera(0,0,20,-40) CameraLookAt(0, 0,0,0) CreateLight(0,$ffffff, 10000, 5000, 2000) AmbientColor($888888) CreateCamera(1,0,0,100,100) CreateRenderTexture(0,CameraID(1),ScreenWidth()/1,ScreenHeight()/1) CreateMaterial(1,TextureID(0)) SetMaterialAttribute(1,#PB_Material_ProjectiveTexturing,1) LoadTexture(1, "MRAMOR6X6.jpg") AddMaterialLayer(1,TextureID(1),#PB_Material_Modulate) CreatePlane(1,100,100,1,1,4,4) CreateEntity(1,MeshID(1),MaterialID(1)) SetupMaterial(2, "RustySteel.jpg",2) SetupMaterial(3, "dirt.jpg",2) SetupMaterial(4, "soil_wall.jpg",2) SetupMaterial(5, "wood.jpg",8) CreateIcoSphere(0,3,3) For i=100 To 150 CreateEntity(i,MeshID(0),MaterialID(2+Random(3)),pom(32),pom(4),pom(32)) ScaleEntity(i,1,1+pom(0.7),1) RotateEntity(i,pom(180),pom(180),pom(180)) Next Repeat Screen3DEvents() ExamineMouse() MouseX = -MouseDeltaX() * 0.05 MouseY = -MouseDeltaY() * 0.05 ExamineKeyboard() ap+(-Bool(KeyboardPushed(#PB_Key_Left))+Bool(KeyboardPushed(#PB_Key_Right)))*0.01 dp-(-Bool(KeyboardPushed(#PB_Key_Down))+Bool(KeyboardPushed(#PB_Key_Up )))*0.1 If KeyboardReleased(#PB_Key_F12) : fdf=1-fdf : If fdf : CameraRenderMode(0,#PB_Camera_Wireframe) : Else : CameraRenderMode(0,#PB_Camera_Textured) : EndIf : EndIf a+0.002 MoveCamera(0,Cos(a)*50,10,Sin(a)*50,#PB_Absolute) CameraLookAt(0,0,0,0) co=Cos(ap) si=Sin(ap) MoveEntity(1,si*dp,-co*dp,0,0) EntityDirection(1, si, co, 0, #PB_World, #PB_UNIT_Y) CameraReflection(1,0,EntityID(1)) RenderWorld() FlipBuffers() Until KeyboardPushed(#PB_Key_Escape) EndIf Else MessageRequester("Ошибка","3D Движок не может быть инициализирован") EndIf