Vous allez me dire que je n'ai qu'à supprimer cet entité mais ce n'est pas ce que je veux
Touche Espace pour rendre le cube invisible ou visible.
Code : Tout sélectionner
EnableExplicit
Enumeration
#Mainform
EndEnumeration
Global WWIdth, WHeight
Global Event
Global CamX.f, CamY.f
Global Camera, Texture, Material, Mesh, Entity, Hide.b
InitEngine3D()
InitKeyboard()
InitSprite()
OpenWindow(#Mainform,0,0, 0, 0, "", #PB_Window_SystemMenu | #PB_Window_Maximize)
WWidth = WindowWidth(#Mainform, #PB_Window_InnerCoordinate)
WHeight = WindowHeight(#Mainform, #PB_Window_InnerCoordinate)
OpenWindowedScreen(WindowID(#Mainform),0,0,WWIdth,WHeight,0, 0, 0)
KeyboardMode(#PB_Keyboard_International)
;Lumiere et ombre
AmbientColor(RGB(127, 127, 127))
CreateLight(#PB_Any,RGB(151, 251, 151), -1.8, 10, 5)
WorldShadows(#PB_Shadow_Additive)
;Camera
Camera = CreateCamera(#PB_Any,0,0,100,100)
CameraBackColor(Camera, RGB(145, 182, 201))
MoveCamera(Camera, 0, 5, 10, #PB_Absolute)
CameraLookAt(Camera, 0,0,0)
;Sol
Mesh = CreatePlane(#PB_Any, 20, 20, 1, 1, 1, 1)
CreateEntity(#PB_Any, MeshID(Mesh), #PB_Material_None)
;un cube
;Texture une couche alpha (Fond jaune et contour noir)
Texture = CreateTexture(#PB_Any,512,512)
StartDrawing(TextureOutput(Texture))
DrawingMode(#PB_2DDrawing_AllChannels)
Box(0,0,512,512,RGBA(0, 0, 0, 255))
Box(4,4,504,504,RGBA(255, 215, 0, 255))
StopDrawing()
;Matériel
Material = CreateMaterial(#PB_Any, TextureID(Texture))
MaterialBlendingMode(Material, #PB_Material_AlphaBlend)
;Mesh
Mesh = CreateCube(#PB_Any, 2)
;Entité
Entity = CreateEntity(#PB_Any, MeshID(Mesh), MaterialID(Material), 0, 1, 0)
RotateEntity(Entity, 0, 45, 0)
Repeat
Repeat
Event = WindowEvent()
Select Event
Case #PB_Event_CloseWindow
End
EndSelect
Until Event = 0
If ExamineKeyboard()
If KeyboardPushed (#PB_Key_Escape)
Break
EndIf
If KeyboardReleased (#PB_Key_Space)
If Hide = #False
SetMaterialColor(Material, #PB_Material_DiffuseColor, RGBA(0, 0, 0, 0))
Hide = #True
Else
SetMaterialColor(Material, #PB_Material_DiffuseColor, RGBA(255, 255, 255, 255))
Hide = #False
EndIf
EndIf
EndIf
; Affiche le rendu de la scène
ClearScreen(RGB(0, 0, 0))
RenderWorld(80)
FlipBuffers()
ForEver