Sindba à la piscine

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 :

Sindba à la piscine

Message par falsam »

Certains d'entres vous connaissent déja ce code que j'ai présenté sur le forum anglais.

Code : Tout sélectionner

EnableExplicit

;Police
Global FontInfo = LoadFont(-1, "Arial", 12)

;Textures
Global MatGround, MatBox, MatBuoy 

;Entities
Global Camera, CameraHeight = 125, Brother, Player, PlayerSpeed, CurrentAnimation.s, Angle = 180, Distance = 500
Global Ground, Box, buoy0, buoy1

;Dust emiter / Emetteur de poussieres
Global NewList Emiters()

;Sprite 
Global Bottom

;Init engine
If Not (InitEngine3D() And InitSprite() And InitKeyboard())
  End
EndIf

OpenWindow(0, 0, 0, 0, 0, "", #PB_Window_BorderLess | #PB_Window_Maximize)
OpenWindowedScreen(WindowID(0), 0, 0, WindowWidth(0), WindowHeight(0))

;The elements are in the examples folder of PureBasic
Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Water", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Packs/desert.zip", #PB_3DArchive_Zip)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Packs/waterworld.zip", #PB_3DArchive_Zip)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Packs/Sinbad.zip", #PB_3DArchive_Zip)
Parse3DScripts()

KeyboardMode(#PB_Keyboard_International | #PB_Keyboard_AllowSystemKeys)
EnableWorldPhysics(#True)
EnableWorldCollisions(#True)
WorldGravity(-10)

;-[2D] Create ou load sprite
Bottom = CreateSprite(-1, ScreenWidth(), 150, #PB_Sprite_AlphaBlending)

;-[3D] Create ou load 3D element

;-Textures & material
MatGround  = CreateMaterial(-1, TextureID(LoadTexture(-1, "Floor02.jpg")))        ;Ground
ScaleMaterial(MatGround, 0.5, 0.5)
MatBox     = CreateMaterial(-1, TextureID(LoadTexture(-1, "Caisse.png")))         ;Box
MatBuoy    = CreateMaterial(-1, TextureID(LoadTexture(-1, "ogrelogo-small.jpg"))) ;Buoy

;-Camera
Camera = CreateCamera(-1, 0, 0, 100, 100)

;Sky and fog
SkyBox("desert07.jpg")

;-Light and shadow
CreateLight(0, RGB(255, 255, 255), -100, 500, 100)
;WorldShadows(#PB_Shadow_Modulative) ;Fontionne pas
WorldShadows(#PB_Shadow_TextureAdditive, 1000, RGB(0,0,0), 2048)

;-Sea
Sun(0, 10000, 10000, RGB(255, 255, 255))
CreateWater(Camera, 0, 135, 0, 0, #PB_World_WaterLowQuality | #PB_World_WaterSmooth)

;-Ground
Ground = CreateEntity(-1, MeshID(CreateCube(-1, 1)), MaterialID(MatGround), -1000, 0, 0)
ScaleEntity(Ground, 1000, 300, 1000)
CreateEntityBody(Ground, #PB_Entity_StaticBody)
EntityRenderMode(Ground, 0)

Ground = CreateEntity(-1, MeshID(CreateCube(-1, 1)), MaterialID(MatGround), 0, 0, 0)
ScaleEntity(Ground, 1000, 300, 1000)
CreateEntityBody(Ground, #PB_Entity_StaticBody)
EntityRenderMode(Ground, 0)

Ground = CreateEntity(-1, MeshID(CreateCube(-1, 1)), MaterialID(MatGround), 1000, 0, 0)
ScaleEntity(Ground, 1000, 300, 1000)
CreateEntityBody(Ground, #PB_Entity_StaticBody)
EntityRenderMode(Ground, 0)

Ground = CreateEntity(-1, MeshID(CreateCube(-1, 1)), MaterialID(MatGround), 1000, 0, 1000)
ScaleEntity(Ground, 1000, 300, 1000)
CreateEntityBody(Ground, #PB_Entity_StaticBody)
EntityRenderMode(Ground, 0)

Ground = CreateEntity(-1, MeshID(CreateCube(-1, 1)), MaterialID(MatGround), 1000, 0, 2000)
ScaleEntity(Ground, 1000, 300, 1000)
CreateEntityBody(Ground, #PB_Entity_StaticBody)
EntityRenderMode(Ground, 0)

Ground = CreateEntity(-1, MeshID(CreateCube(-1, 1)), MaterialID(MatGround), -1000, 0, 1000)
ScaleEntity(Ground, 1000, 300, 1000)
CreateEntityBody(Ground, #PB_Entity_StaticBody)
EntityRenderMode(Ground, 0)

Ground = CreateEntity(-1, MeshID(CreateCube(-1, 1)), MaterialID(MatGround), -1000, 0, 2000)
ScaleEntity(Ground, 1000, 300, 1000)
CreateEntityBody(Ground, #PB_Entity_StaticBody)
EntityRenderMode(Ground, 0)

Ground = CreateEntity(-1, MeshID(CreateCube(-1, 1)), MaterialID(MatGround), 0, 0, 2000)
ScaleEntity(Ground, 1000, 300, 1000)
CreateEntityBody(Ground, #PB_Entity_StaticBody)
EntityRenderMode(Ground, 0)

;-Box
Box = CreateEntity(-1, MeshID(CreateCube(-1, 100)), MaterialID(MatBox), -500, 200, 0)
CreateEntityBody(Box, #PB_Entity_StaticBody)

;-Player
Player = CreateEntity(-1, MeshID(LoadMesh(#PB_Any, "sinbad.mesh")), #PB_Material_None, 10, 275, -40)
ScaleEntity(Player, 25, 25, 35)
CreateEntityBody(Player, #PB_Entity_ConvexHullBody, 1, 3, 40)
EntityAngularFactor(Player, 0, 1, 0)
RotateEntity(Player, 0, -120, 0)

;-Brother
Brother = CreateEntity(-1, MeshID(LoadMesh(#PB_Any, "sinbad.mesh")), #PB_Material_None, 27, 120, 1000)
ScaleEntity(Brother, 25, 25, 25)
RotateEntity(Brother, -90, 45, 0)

;-Buoy / Bouéée
buoy0 = CreateEntity(-1, MeshID(CreateTorus(-1, 60, 30)), MaterialID(MatBuoy), 0, 140, 700)
buoy1 = CreateEntity(-1, MeshID(CreateTorus(-1, 60, 30)), MaterialID(MatBuoy), 300, 140, 900)
RotateEntity(buoy1, 0, 90, 0)

Repeat
  ;-
  ;-[3D] Rendering
  If ExamineKeyboard()
       
    ;-keyboard events : Distance and move
    If KeyboardPushed(#PB_Key_LeftControl) And KeyboardPushed(#PB_Key_Up)
      Distance - 25
    ElseIf KeyboardPushed(#PB_Key_LeftControl) And KeyboardPushed(#PB_Key_Down) 
      Distance + 25
    ElseIf KeyboardPushed (#PB_Key_Up)
      PlayerSpeed = 400
      CurrentAnimation = "RunBase"
      Angle = 180
    ElseIf KeyboardPushed (#PB_Key_Down)
      PlayerSpeed = -400
      Angle = 0
      CurrentAnimation = "RunBase"
    Else
      CurrentAnimation = "Dance"
      PlayerSpeed = 0
    EndIf
       
    ;-keyboard events : Rotation around player and turn
    If KeyboardPushed(#PB_Key_LeftControl) And KeyboardPushed(#PB_Key_Left)
      Angle - 5
    ElseIf KeyboardPushed(#PB_Key_LeftControl) And KeyboardPushed(#PB_Key_Right)
      Angle + 5
    ElseIf KeyboardPushed (#PB_Key_Left)
      RotateEntity(Player, 0, 3, 0, #PB_Relative)
      CurrentAnimation = "RunBase"
    ElseIf KeyboardPushed (#PB_Key_Right)
      RotateEntity(Player, 0, -3, 0, #PB_Relative)
      CurrentAnimation = "RunBase"
    EndIf   
   
    ;Escape
    If KeyboardReleased(#PB_Key_Escape)
      Break
    EndIf     
  EndIf
 
  DisableEntityBody(Player, #False) ; Wake up entity (BugWare)
  MoveEntity(Player, 0, 0, PlayerSpeed, #PB_Absolute|#PB_Local)     
 
  ;Play animation
  If EntityAnimationStatus(Player, CurrentAnimation) = #PB_EntityAnimation_Stopped
    StartEntityAnimation(Player, CurrentAnimation)
  EndIf
 
  If EntityAnimationStatus(Brother, "IdleTop") = #PB_EntityAnimation_Stopped
    StartEntityAnimation(Brother, "IdleTop")
  EndIf
 
  ;Update buoy, player and friend
  MoveEntity(buoy0, EntityX(buoy0), WaterHeight(Camera, EntityX(buoy0), EntityZ(buoy0)), EntityZ(buoy0), #PB_Absolute)
  MoveEntity(buoy1, EntityX(buoy1), WaterHeight(Camera, EntityX(buoy1), EntityZ(buoy1)), EntityZ(buoy1), #PB_Absolute)
  MoveEntity(Brother, EntityX(Brother), WaterHeight(Camera, EntityX(Brother), EntityZ(Brother)) - 10, EntityZ(Brother), #PB_Absolute)
   
  CameraFollow(Camera, EntityID(Player), Angle, EntityY(Player) + (CameraHeight), Distance, 0.25, 1, #True)
 
  RenderWorld(50)
 
  ;-[2D] Rendering
  StartDrawing(SpriteOutput(Bottom))
  DrawingFont(FontID(FontInfo))
  DrawingMode(#PB_2DDrawing_AlphaChannel)
  Box(0, 0, ScreenWidth(), SpriteWidth(Bottom), RGBA(0, 0, 0, 110))
  DrawingMode(#PB_2DDrawing_Transparent)
  DrawText(10, 10, ". : : Help : : .")
  DrawText(10, 40, "Arrow keys - Move player.")
  DrawText(10, 70, "Ctrl + Up / Ctrl + Down  - Distance between camera and player.")
  DrawText(10, 100, "Ctrl + Left ou Ctrl + Right - Turn around the player.")
  StopDrawing()
  DisplayTransparentSprite(Bottom, 0, ScreenHeight() - SpriteHeight(Bottom))
 
  FlipBuffers()
Until WaitWindowEvent(1) = #PB_Event_CloseWindow
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
SPH
Messages : 4722
Inscription : mer. 09/nov./2005 9:53

Re: Sindba à la piscine

Message par SPH »

sans debugguer : purebasic_compilation0.exe a cessé de fonctionner

avec debugguer : invalide acces memory
:arrow: RenderWorld(50)
http://HexaScrabble.com/
!i!i!i!i!i!i!i!i!i!
!i!i!i!i!i!i!
!i!i!i!
//// Informations ////
Intel Core i7 4770 64 bits - GTX 650 Ti
Version de PB : 6.00 - 64 bits
Avatar de l’utilisateur
Kwai chang caine
Messages : 6962
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Re: Sindba à la piscine

Message par Kwai chang caine »

Kif kif bourique pour moi :wink:

Bah non...je connaissais pas encore le marin "simbad" :D
ImageLe bonheur est une route...
Pas une destination

PureBasic Forum Officiel - Site PureBasic
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Sindba à la piscine

Message par falsam »

Sur mon pc sous Windows 10 Pro DirectX 9c et 11 ce code fonctionne avec ou sans sous-system OpenGl.

J'ai testé ce code avec un pc sous Windows 10 Family DirectX11 seulement et effectivement que ce soit avec ou sans sous-system OpenGl, le code ne fonctionne pas !!
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
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Sindba à la piscine

Message par falsam »

En supprimant

Code : Tout sélectionner

CreateWater(Camera, 0, 135, 0, 0, #PB_World_WaterLowQuality | #PB_World_WaterSmooth)
et en ajoutant le sous-system OpenGl, le code fonctionne mais ne présente plus aucun intérêt !
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%
Patrick88
Messages : 1564
Inscription : mer. 21/janv./2004 18:24

Re: Sindba à la piscine

Message par Patrick88 »

marche impec windows 10 purebasic 5.60 x64

pat
Avatar de l’utilisateur
falsam
Messages : 7244
Inscription : dim. 22/août/2010 15:24
Localisation : IDF (Yvelines)
Contact :

Re: Sindba à la piscine

Message par falsam »

parce que tu dois avoir Directx 9c en plus de DirectX 11 :wink:
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%
Patrick88
Messages : 1564
Inscription : mer. 21/janv./2004 18:24

Re: Sindba à la piscine

Message par Patrick88 »

DirectX 12
G-Rom
Messages : 3627
Inscription : dim. 10/janv./2010 5:29

Re: Sindba à la piscine

Message par G-Rom »

Ogre fourni un .log qui accompagne l'exe, il explique 95% des erreurs. si on ne le poste pas, on ne peu pas savoir ce qui cloche.
comme j'ai participé au dev de la partie 3D, et que j'étais en majeur partie du temps sur linux, y a pas de raison que le code ne fonctionne pas, ici il fonctionne très bien.
Avatar de l’utilisateur
Kwai chang caine
Messages : 6962
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Re: Sindba à la piscine

Message par Kwai chang caine »

Bon, j'ai retesté sur une nouvelle machine W10 X64 v5.61 X86 et exactement ce que tu dis FALSAM, hier c'était sous W7 X86 :wink:
Sauf que y'a quand même un petit intérêt de voir HULK de dos 8)
G-Rom a écrit :Ogre fourni un .log qui accompagne l'exe,
Je vais encore gagner une tringle à rideau en posant une question à la con :oops:
"OGRE.exe" il est où dans PB ? inclus dedans ? je l'ai pas trouvé dans l'arborescence PB..et donc à fortiori son LOG :|
ImageLe bonheur est une route...
Pas une destination

PureBasic Forum Officiel - Site PureBasic
G-Rom
Messages : 3627
Inscription : dim. 10/janv./2010 5:29

Re: Sindba à la piscine

Message par G-Rom »

y a pas de question bête. ton .log doit se trouvé là ou ton .pb est.
je viens de vérifié , il faut aussi maintenant ( je ne sais pas depuis combien de temps ) activé le log via

Code : Tout sélectionner

InitEngine3D(#PB_Engine3D_DebugLog)
Avatar de l’utilisateur
Kwai chang caine
Messages : 6962
Inscription : sam. 23/sept./2006 18:32
Localisation : Isere

Re: Sindba à la piscine

Message par Kwai chang caine »

Merci beaucoup GRom 8)
Si ça intéresse .....je pourrais donc remonter le LOG OGRE de W7 quand j'aurais la main dessus, si quelqu'un l'a pas fait avant bien sûr :wink:
ImageLe bonheur est une route...
Pas une destination

PureBasic Forum Officiel - Site PureBasic
Répondre