PureBasic

Forums PureBasic
Nous sommes le Sam 25/Mai/2013 5:44

Heures au format UTC + 1 heure




Poster un nouveau sujet Répondre au sujet  [ 3 messages ] 
Auteur Message
 Sujet du message: SpecialEffects
MessagePosté: Jeu 05/Avr/2012 16:19 
Hors ligne

Inscription: Mer 14/Sep/2011 16:59
Messages: 335
Où puis-je trouver des exemples utilisant cette bibliothèque ?
(La doc est vraiment pauvre).

Mesa.


Haut
 Profil  
 
 Sujet du message: Re: SpecialEffects
MessagePosté: Ven 20/Avr/2012 10:00 
Hors ligne
Avatar de l’utilisateur

Inscription: Sam 19/Fév/2011 12:46
Messages: 907
salut

je n'en ai pas trouvé non.

Voici ce que j'ai essayé de faire, mais sans résultat :


Il faut placer ce fichier dans le répertoire des exemples 3D de purebasic.
Code:
;
; ------------------------------------------------------------
;
;   PureBasic - PointJoint (Bridge)
;
;    (c) 2011 - Fantaisie Software
;
; ------------------------------------------------------------
;

IncludeFile "Screen3DRequester.pb"

#CameraSpeed = 1
#Nb = 30
Enumeration
#bloom
#motionblur
EndEnumeration

Define.f KeyX, KeyY, MouseX, MouseY
Global effect.a,keypressed.a
Dim Planche(#Nb)

If InitEngine3D()

  Add3DArchive("Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive("Data/Scripts",#PB_3DArchive_FileSystem)
  Add3DArchive("Data/Packs/desert.zip", #PB_3DArchive_Zip)
  Parse3DScripts()
   
  InitSprite()
  InitKeyboard()
  InitMouse()

  If Screen3DRequester()
   
    KeyboardMode(#PB_Keyboard_International)
   
    WorldShadows(#PB_Shadow_Modulative)
       
    ;Materials
    ;
    CreateMaterial(0, LoadTexture(0, "Wood.jpg"))
    GetScriptMaterial(1, "SphereMap/SphereMappedRustySteel")
    CreateMaterial(2, LoadTexture(2, "Dirt.jpg"))
    GetScriptMaterial(3, "Scene/GroundBlend")
   

    ; Ground
    ;
    CreatePlane(3, 10000, 10000, 100, 100, 150, 150)
    CreateEntity(3,MeshID(3),MaterialID(3), 0, -50, 0)
    EntityRenderMode(3, 0)
    EntityPhysicBody(3, #PB_Entity_StaticBody)
   
    ; Bridge
    CreateCube(1, 1.0)
    For i = 1 To #Nb
      Planche(i)=CreateEntity(#PB_Any, MeshID(1), MaterialID(0))
      ScaleEntity(Planche(i), 2.8, 0.8, 20)
      EntityLocate(Planche(i), i * 3, 0, 0)
      EntityPhysicBody(Planche(i), #PB_Entity_BoxBody, 1.0)
    Next i
   
    Pas.f = 1.5
    PointJoint(Planche(1),  -Pas, 0, -5)
    For i= 1 To #Nb-2
      PointJoint(Planche(i+1),  -Pas, 0, -5, Planche(i), Pas, 0, -5)
    Next i
    PointJoint(Planche(#Nb),  Pas, 0, -5)
    PointJoint(Planche(#Nb-1),  Pas, 0, -5, Planche(#Nb), -Pas, 0, -5)
   
    PointJoint(Planche(1),  -Pas, 0, 5)
    For i= 1 To #Nb-2
      PointJoint(Planche(i+1),  -Pas, 0, 5, Planche(i), Pas, 0, 5)
    Next i
    PointJoint(Planche(#Nb),  Pas, 0, 5)
    PointJoint(Planche(#Nb-1),  Pas, 0, 5, Planche(#Nb), -Pas, 0, 5)
   
    ; Objects
    ;
    CreateSphere(2, 2, 30, 30)
   
    C = Planche(1)
    For i = 1 To #Nb/2
      Perso = CreateEntity(#PB_Any, MeshID(2), MaterialID(1), EntityX(C) +i * 5, EntityY(C)+ i * 2, EntityZ(C))
      EntityPhysicBody(Perso, #PB_Entity_SphereBody, 0.5)
    Next i
   
    For i = 1 To #Nb/2
      Perso = CreateEntity(#PB_Any, MeshID(1), MaterialID(2), EntityX(C) +i * 5, EntityY(C)+ i * 4, EntityZ(C))
      ScaleEntity(Perso, 3, 3, 3)
      EntityPhysicBody(Perso, #PB_Entity_BoxBody, 1.0)
    Next i
   
    ; Camera
    ;
    CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0, -20, 30, -40)
    CameraLookAt(0, EntityX(C) + 25, EntityY(C) + 10,  EntityZ(C))
   
    ; les effects
    If CreateCompositorEffect(#bloom,CameraID(0),GetCurrentDirectory()+"Data\Scripts\bw.compositor") = 0
      MessageRequester("error","unable to load or create the compositor effect")
    Else
      Debug GetCurrentDirectory()+"Data\Scripts\bw.compositor"     
    EndIf
   
    If CreateCompositorEffect(#motionblur,CameraID(0),GetCurrentDirectory()+"Data\Scripts\motionblur.compositor")=0
      MessageRequester("error","unable to load or create the compositor effect")
    EndIf

    ;SkyBox
    ;
    SkyBox("desert07.jpg")
   
    ; Light
    ;
    CreateLight(0, RGB(255, 255, 255), 100, 800, -500)
    AmbientColor(RGB(20, 20, 20))
   
    Repeat
      Screen3DEvents()
     
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
     
      If ExamineKeyboard()
               
        If KeyboardPushed(#PB_Key_Space)
          ApplyEntityImpulse(Planche(#Nb/2), 0, 9, 0)
        EndIf
        If KeyboardPushed(#PB_Key_Return)
          FreeJoint(Planche(#Nb/2))
        EndIf     
       
        If KeyboardPushed(#PB_Key_Left)
          KeyX = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Right)
          KeyX = #CameraSpeed
        Else
          KeyX = 0
        EndIf
       
        If KeyboardPushed(#PB_Key_Up)
          KeyY = -#CameraSpeed
        ElseIf KeyboardPushed(#PB_Key_Down)
          KeyY = #CameraSpeed
        Else
          KeyY = 0
        EndIf
               
        If KeyboardReleased(#PB_Key_F3)
          Debug "effet"
          If IsEffect(#bloom)               
            HideEffect(#bloom,1)
          EndIf
        EndIf
       
        If KeyboardReleased(#PB_Key_F2)
          Debug "pas d'effet"
          If IsEffect(#bloom)               
            HideEffect(#bloom,0)
          EndIf
        EndIf
       
      EndIf
           
      MoveCamera  (0, KeyX, 0, KeyY)
      RotateCamera(0,  MouseY, MouseX, 0, #PB_Relative)
     
      RenderWorld()
      Screen3DStats()
      FlipBuffers()     
    Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
   
  EndIf

Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End



Les effets à placer dans le répertoire :
Data\Scripts

Effet bloom (bloom.compositor):
Code:
/// Manuel's bloom
/// Needs a scene-sized rtt, but does only one render of the scene
compositor Bloom
{
    technique
    {
        // Temporary textures
        texture scene target_width target_height PF_A8R8G8B8
        texture rt0 128 128 PF_A8R8G8B8
        texture rt1 128 128 PF_A8R8G8B8

        target scene
        {
            // Render output from previous compositor (or original scene)
            input previous
        }
        target rt0
        {
            // Start with clear texture
            input none
            // Vertical blur pass
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material PostFilters/Blur0
                input 0 scene
            }
        }
        target rt1
        {
            // Start with clear texture
            input none
            // Horizontal blur pass
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material PostFilters/Blur1
                input 0 rt0
            }
        }
        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material PostFilters/BloomBlend
                input 0 scene
                input 1 rt1
            }
        }
    }
}


Effet black & white (bw.compositor):
Code:
/// Black and white effect
compositor B&W
{
    technique
    {
        // Temporary textures
        texture scene target_width target_height PF_A8R8G8B8

        target scene
        {
            // Render output from previous compositor (or original scene)
            input previous
        }
        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the blur
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material PostFilters/BlackAndWhite
                input 0 scene
            }
        }
    }
}


Effet motion blur (motionblur.compositor) :
Code:
/// Manuel's motion blur effect
compositor "Motion Blur"
{
    technique
    {
        // Temporary textures
        texture scene target_width target_height PF_A8R8G8B8
        texture sum target_width target_height PF_A8R8G8B8
        texture temp target_width target_height PF_A8R8G8B8

        target scene
        {
            // Render output from previous compositor (or original scene)
            input previous
        }
        target sum
        {
            // Render this target pass only initially, on the first frame that
            // this effect was enabled. This makes sure the sum texture
            // does not start with randomness.
            only_initial on

            input previous
        }
        target temp
        {
            // Start with clear texture
            input none
            // Combine scene and sum texture
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositors/Combine
                input 0 scene
                input 1 sum
            }
        }
        target sum
        {
            // Start with clear texture
            input none
            // Copy temporary back to sum
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositors/Copyback
                input 0 temp
            }
        }
        target_output
        {
            // Start with clear output
            input none
            // Draw a fullscreen quad with the blur
            pass render_quad
            {
                // Renders a fullscreen quad with a material
                material Ogre/Compositors/MotionBlur
                input 0 sum
            }
        }
    }
}


Si tu parviens à obtenir un résultat, surtout, n'hésites pas à poster le code, car je suis vraiment intéressé moi aussi :D.

_________________
http://blendman.blogspot.com/


Haut
 Profil  
 
 Sujet du message: Re: SpecialEffects
MessagePosté: Sam 21/Avr/2012 10:26 
Hors ligne

Inscription: Mer 14/Sep/2011 16:59
Messages: 335
Ça ne marche pas non plus chez moi et comme je n'y connais rien en 3D...

Mais, on peut bucher cette page :
http://www.ogre3d.org/tikiwiki/Composit ... e=Cookbook
rubrique : BNF grammer for script

Si on prends l'effet black & white (bw.compositor) comme exemple.
La ligne "material PostFilters/BlackAndWhite" devrait être adapté selon le cas et d'ailleur ça devrait être un label, toujours d'après http://www.ogre3d.org/tikiwiki/Composit ... e=Cookbook
rubrique : BNF grammer for script
Je pense que le script recherche un 'material' qu'il ne trouve pas.
Ou plutôt, je pense qu'il cherche un fichier '.material'
http://www.ogre3d.org/docs/manual/manual_14.html#SEC23
http://www.ogre3d.org/tikiwiki/Material ... e=Cookbook
En français
http://www.siteduzero.com/tutoriel-3-47 ... riaux.html

Un petit tuto en c++
http://gusgus.developpez.com/Ogre/
<<<<<< EXCELLENT pour savoir où l'on va >>>>>>>>>>>>
http://www.siteduzero.com/tutoriel-3-33 ... re-3d.html
<<<<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>

Peut-être faut-il se pencher sur la fonction purebasic : CompositorEffectParameter()

Est-elle indispensable pour le fonctionnement des effets spéciaux ?

Désolé de ne pouvoir faire plus.

Mesa.


Haut
 Profil  
 
Afficher les messages postés depuis:  Trier par  
Poster un nouveau sujet Répondre au sujet  [ 3 messages ] 

Heures au format UTC + 1 heure


Qui est en ligne

Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 0 invités


Vous ne pouvez pas poster de nouveaux sujets
Vous ne pouvez pas répondre aux sujets
Vous ne pouvez pas éditer vos messages
Vous ne pouvez pas supprimer vos messages

Rechercher:
Aller à:  

 


Powered by phpBB © 2008 phpBB Group | Traduction par: phpBB-fr.com
subSilver+ theme by Canver Software, sponsor Sanal Modifiye