[Résolu] Entité invisible : Comment supprimer l'ombre ?

Généralités sur la programmation 3D
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

[Résolu] Entité invisible : Comment supprimer l'ombre ?

Message par falsam »

Je souhaite rendre une entité invisible quand on presse la touche Espace par exemple. Le souci est que je ne sais pas me débarrasser de l'ombre.

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
Merci de votre aide.
Dernière modification par falsam le jeu. 17/avr./2014 16:43, modifié 1 fois.
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Avatar de l’utilisateur
graph100
Messages : 1318
Inscription : sam. 21/mai/2005 17:50

Re: Entité invisible : Comment supprimer l'ombre

Message par graph100 »

Voila chef !

Code : Tout sélectionner

EntityRenderMode(Entity, 0)

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))
				EntityRenderMode(Entity, 0)
				
				Hide = #True
			Else
				SetMaterialColor(Material, #PB_Material_DiffuseColor, RGBA(255, 255, 255, 255))
				EntityRenderMode(Entity, #PB_Entity_CastShadow)
				
				Hide = #False
			EndIf
		EndIf
		
	EndIf
		
	; Affiche le rendu de la scène
	ClearScreen(RGB(0, 0, 0))
	RenderWorld(80)
	FlipBuffers()    
ForEver
_________________________________________________
Mon site : CeriseCode (Attention Chantier perpétuel ;))
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Entité invisible : Comment supprimer l'ombre

Message par falsam »

Rhooooo mais pourquoi j'ai loupé cette information !!!! Merci Graph. Ça servira quand même pour d'autres :)
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
comtois
Messages : 5172
Inscription : mer. 21/janv./2004 17:48
Contact :

Re: [Résolu] Entité invisible : Comment supprimer l'ombre ?

Message par comtois »

HideEntity() ne convient pas ?
http://purebasic.developpez.com/
Je ne réponds à aucune question technique en PV, utilisez le forum, il est fait pour ça, et la réponse peut profiter à tous.
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: [Résolu] Entité invisible : Comment supprimer l'ombre ?

Message par falsam »

comtois a écrit :HideEntity() ne convient pas ?
Je crois que je vais réviser les fonctions 3D :oops:
Configuration : Windows 11 Famille 64-bit - PB 6.03 x64 - AMD Ryzen 7 - 16 GO RAM
Vidéo NVIDIA GeForce GTX 1650 Ti - Résolution 1920x1080 - Mise à l'échelle 125%
Répondre