; ; ------------------------------------------------------------ ; ; PureBasic - VisibilityMask ; ; (c) Fantaisie Software ; ; ------------------------------------------------------------ ; IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb" Define.f KeyX, KeyY, MouseX, MouseY, SpriteX, SpriteY LoadFont(0, "Verdana", 24, #PB_Font_Bold) #Mask1 = 1 << 0 #Mask2 = 1 << 1 #Mask3 = 1 << 2 Macro CreateTexture2(No, Color, Texte) CreateTexture(No, 256, 256) StartDrawing(TextureOutput(No)) Box(0, 0, 256, 256, Color) DrawingMode(#PB_2DDrawing_Transparent) DrawingFont(FontID(0)) DrawText(30, 128, Texte, RGB(255, 255, 255)) StopDrawing() EndMacro If InitEngine3D() Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem) Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Models", #PB_3DArchive_FileSystem) Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Scripts", #PB_3DArchive_FileSystem) Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/desert.zip", #PB_3DArchive_Zip) Parse3DScripts() InitSprite() InitKeyboard() InitMouse() If Screen3DRequester() WorldShadows(#PB_Shadow_Modulative) ;- Земля (Ground) CreateMaterial(0, LoadTexture(0, "Dirt.jpg")) CreatePlane(0, 1500, 1500, 40, 40, 15, 15) CreateEntity(0,MeshID(0),MaterialID(0)); Always visible (visibility mask = $FFFF FFFF) EntityRenderMode(0, 0) ;- Сетка (Mesh) CreateCube(1, 100) ; - Материал GetScriptMaterial(1, "Color/Blue") GetScriptMaterial(2, "Color/Green") GetScriptMaterial(3, "Color/Red") ; - Сущность (Entity) CreateEntity(1, MeshID(1), MaterialID(1), -100, 50, 0, -1, #Mask1) ; Visible by camera 0 CreateEntity(2, MeshID(1), MaterialID(2), 0, 50, 0, -1, #Mask2) ; Visible by camera 1 CreateEntity(3, MeshID(1), MaterialID(3), 100, 50, 0, -1, #Mask3) ; Visible by camera 2 ;- Билборд (BillBoard) CreateTexture2(11, RGB( 0, 0, 255), "Player 1") CreateMaterial(11, TextureID(11)) CreateTexture2(12, RGB( 0, 255, 0), "Player 2") CreateMaterial(12, TextureID(12)) CreateTexture2(13, RGB(255, 0, 0), "Player 3") CreateMaterial(13, TextureID(13)) CreateBillboardGroup(1, MaterialID(11), 100, 100, 0, 0, 0, #Mask1, #PB_Billboard_Point) AddBillboard(1, -100, 180, 0) CreateBillboardGroup(2, MaterialID(12), 100, 100, 0, 0, 0, #Mask2, #PB_Billboard_Point) AddBillboard(2, 0, 180, 0) CreateBillboardGroup(3, MaterialID(13), 100, 100, 0, 0, 0, #Mask3, #PB_Billboard_Point) AddBillboard(3, 100, 180, 0) ; - Камера CreateCamera(0, 0, 0, 50, 50, #Mask1) ; Сущность (Entity) 1 visible MoveCamera(0, 0, 120, 500, #PB_Absolute) CreateCamera(1, 50, 0, 50, 50, #Mask2); Сущность (Entity) 2 visible MoveCamera(1, 0, 120, 500, #PB_Absolute) CreateCamera(2, 0, 50, 50, 50, #Mask3); Сущность (Entity) 3 visible MoveCamera(2, 0, 120, 500, #PB_Absolute) CreateCamera(3, 50, 50, 50, 50, #Mask1 | #Mask3) ; entities 1 & 3 visibles MoveCamera(3, 0, 120, 500, #PB_Absolute) ; - Свет CreateLight(0, RGB(255, 255, 255), -40, 300, 80) AmbientColor(RGB(80, 80, 80)) ;- СкайБокс (SkyBox) SkyBox("Desert07.jpg") Repeat Screen3DEvents() ExamineMouse() ExamineKeyboard() RenderWorld() FlipBuffers() Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1 EndIf Else MessageRequester("Ошибка", "3D Движок не может быть инициализирован",0) EndIf End