Colour fade transitions between two 3D scenes

Everything related to 3D programming
gavindi
User
User
Posts: 41
Joined: Mon Jan 21, 2013 12:57 am

Colour fade transitions between two 3D scenes

Post by gavindi »

Hi,

I'm prototyping a game at the moments and I have two 3D scenes. The first is the title screen and the second is the game scene. When the player presses starts, I would like to fade the scene to white or black (or any other colour for that matter) but I can't think of a way to do this other than to create an all-consuming fog.

Or maybe a giant translucent billboard that takes the whole screen and is transitions to opaque and back again when the scene underneath is ready.

I thought I'd ask for suggestions on what is the coolest, best looking approach to this.

Cheers,
G.
Using Ubuntu 14.04 x64, Intel4700HD Graphics, 16GB RAM
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Colour fade transitions between two 3D scenes

Post by Comtois »

just added few lines in MaterialTranparent.pb example

Press space bar to start fading

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Material Transparent
;
;    (c) 2012 - Fantaisie Software
;
; ------------------------------------------------------------
;

#CameraSpeed = 1

IncludeFile "Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY, RollZ, Blend, Pas = 0.7 

If InitEngine3D()
  
  Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Models", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Packs/skybox.zip", #PB_3DArchive_Zip)
  Add3DArchive("Data/Scripts", #PB_3DArchive_FileSystem)
  Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    CreatePlane(0, 500, 500, 10, 10, 1, 1)
    CreateSphere(1, 5)
    
    CreateTexture(0, 256, 256)
    StartDrawing(TextureOutput(0))
    DrawingMode(#PB_2DDrawing_AllChannels | #PB_2DDrawing_AlphaBlend)
    Box(0, 0, 256, 256, RGBA(0, 0, 0, 255)) 
    StopDrawing()
    
    CreateMaterial(0, TextureID(0))
    
    MaterialBlendingMode(0, #PB_Material_AlphaBlend)
    
    CreateEntity(0, MeshID(0), MaterialID(0), 0, 0, 250)  
    RotateEntity(0, 90, 0, 0)
    
    SkyBox("stevecube.jpg")
    
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 0, 8, 300, #PB_Absolute)
    
    Repeat
      Screen3DEvents()
      
      ExamineKeyboard()
      If KeyboardReleased(#PB_Key_Space)
        BlendMode = 1
      EndIf
      
      If BlendMode
        Blend + pas
      EndIf
      
      If blend >= 255 
        BlendMode = 0
        blend = 255
      EndIf  
      
      SetMaterialColor(0, #PB_Material_DiffuseColor, RGBA(255, 255, 255, Blend))
      
      
      CameraLookAt(0, EntityX(0), EntityY(0), EntityZ(0))
      RenderWorld()
      
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  EndIf
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End 
Please correct my english
http://purebasic.developpez.com/
gavindi
User
User
Posts: 41
Joined: Mon Jan 21, 2013 12:57 am

Re: Colour fade transitions between two 3D scenes

Post by gavindi »

Awesome suggestion Comtois, thanks. I do notice that no matter what, my Text3D stays in front of the plane. This happens even if I move the text back through the Z coord.
Using Ubuntu 14.04 x64, Intel4700HD Graphics, 16GB RAM
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Colour fade transitions between two 3D scenes

Post by Comtois »

add a line to fade your text

Code: Select all

 Text3DColor(0, RGBA(255, 0, 0, 255-blend))
Please correct my english
http://purebasic.developpez.com/
Post Reply