Particules et environnement 2D

Généralités sur la programmation 3D
Dräc
Messages : 526
Inscription : dim. 29/août/2004 0:45

Message par Dräc »

Voici la version PB4 du code de cederavic (donné au début de ce post)

Je constate qu’il n’est plus possible d’avoir un arriere plan en 2D et une couche 3D par-dessus…

Que c’est-il passé avec Ogre et la v4 de PB !?! 8O

[EDITE] La correction sera faite lors de la prochaine fourniture de PBv4

Code : Tout sélectionner

InitEngine3D()
InitSprite()


OpenWindow(0, 0, 0, 640, 480, "2D / 3D", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)
 
  CreateSprite(0, 1280, 480)
  StartDrawing(SpriteOutput(0))
    For t = 0 To 2000
      c = Random(245) + 10
      Circle(Random(1279), Random(479), Random(6) + 1, RGB(c, c, c))
    Next
  StopDrawing()
 
  CreateSprite(1, 1280, 480)
  StartDrawing(SpriteOutput(1))
    For t = 0 To 100
      Circle(Random(1279), Random(479), Random(16) + 8, Random(#White))
    Next
  StopDrawing()
 
  CreateTexture(0, 32, 32)
  StartDrawing(TextureOutput(0))
    For t = 1 To 16
      c = t * 16
      Circle(16, 16, 16 - t, RGB(c, c, c))
    Next
  StopDrawing()
 
 
  CreateMaterial(0, TextureID(0))
      DisableMaterialLighting(0, 1)
      MaterialBlendingMode   (0, 1)
   
  For x = -100 To 100 Step 20
    CreateParticleEmitter(n, 10, 1, 1, 0)
      ParticleMaterial    (n, MaterialID(0))
      ParticleTimeToLive  (n, 2, 2)
      ParticleEmissionRate(n, 20)
      ParticleSize        (n, 30, 30)
      ParticleColorRange  (n, Random(#White), Random(#White))
      ParticleEmitterLocate(n, x, 0, 0)
    n + 1
  Next
 
  CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0, 0, 200, 200)
    CameraLookAt(0, 0, 0, 0)
    CameraBackColor(0, -1)
 
  Repeat
 
    Repeat
   
      wEvent = WindowEvent()
     
      Select wEvent
       
        Case #WM_CLOSE
          Quit = #True
     
      EndSelect
     
    Until wEvent = #False
   
    ;- Arriere plan
    ClearScreen(RGB(0,0,64))
   
    x0 + 8
    If x0 > 1280
      x0 = 0
    EndIf
   
    ClipSprite(0, x0, 0, 640, 480)
    DisplayTransparentSprite(0, 0, 0)
   
    ClipSprite(0, 0, 0, x0 - 640, 480)
    DisplayTransparentSprite(0, 1280 - x0, 0)
   
    ;- 3D
    a.f + 0.02
    z.f = 300 * Cos(a)
    y.f = 300 * Sin(a)
    CameraLocate(0, y, y, z)
    CameraLookAt(0, 0, 0, 0)
    RenderWorld()
   
    ;- Premier plan
    x1 + 3
    If x1 > 1280
      x1 = 0
    EndIf
   
    ClipSprite(1, x1, 0, 640, 480)
    DisplayTransparentSprite(1, 0, 0)
   
    ClipSprite(1, 0, 0, x1 - 640, 480)
    DisplayTransparentSprite(1, 1280 - x1, 0)
   
    FlipBuffers()
   
  Until Quit = #True
Avatar de l’utilisateur
cederavic
Messages : 1338
Inscription : lun. 09/févr./2004 23:38
Localisation : Bordeaux

Message par cederavic »

1 an après... Ben.. ça marche :D
Répondre