Developpez.com - Rubrique PureBasic

Le Club des Développeurs et IT Pro

PureBasic 4.60 bêta 1 est disponible

Cette version est principalement axée sur la 3D.

Le 2011-04-04 09:05:53, par comtois, Responsable Purebasic
Hello everybody!

You probably saw the fake April 1 announcement, but as we all know: real releases happen on a Monday! So here it is, after a longer than usual period: The first beta of the upcoming PureBasic 4.60 release. It is available for download on your personal account.

This release is mostly about the 3D side of things, but there are new features for application programmers as well. The OGRE engine was updated to version 1.7.0 and we switched the physics engine from ODE to Bullet. Furthermore, there are a ton of new 3D libraries and commands. You can see the full list below. The 3D commands are not documented yet, but we will put up some examples to demonstrate them.

A special thanks to G-Rom and TMyke from the french forum for their help on the new 3D commands!

Note: It may be required that you update your DirectX 9 runtimes to work with this new version. If you get a missing DLL error when running the 3D examples, then install this: http://www.microsoft.com/downloads/

On the application side of things, the most notable addition is the CanvasGadget() command. It is a simple drawing surface that provides detailed mouse and keyboard events to easily implement custom data views or controls (all cross-platform of course). You can see this new gadget in action in the IDE already: The new file panel and the new color picker tool both make use of it. Other than that, there are some smaller new commands like additions to the LinkedList library for example. All new non-3D commands are already documented in the manual.

The IDE got some additions as well, like the ability to build projects directly from the command-line, or the option to be warned when a file is changed on disk while open in the IDE. Unfortunately, the automation framework that I talked about here on the forum did not make it into this release. It wasn't finished in time, and its not a big enough priority to justify delaying this release any longer.

Finally, we are in the process of changing the PureBasic documentation to be more precise and readable when it comes to function parameters and return values. This is still a work in progress which should be finished for the final release. Comments on the new structure are welcome.
Voici la liste complète des nouveautés :

Libraries:
- added CanvasGadget(), CanvasOutput()
- added SetGadgetItemData() for PanelGadget
- added MoveElement(), MergeLists(), SplitList() commands
- added RandomizeList(), RandomizeArray()
- added PushListPosition(), PopListPosition(), PushMapPosition(), PopMapPosition()
- added ImageID parameter to OpenSubMenu()
- added #PB_ListIcon_ThreeState and #PB_ListIcon_Inbetween
- added #PB_Tree_ThreeState and #PB_Tree_Inbetween
- added crossplatform ComboBox events
- added 'Joint' library
- added 'SpecialEffect' library
- added 'StaticGeometry' library
- added CameraPitch(), CameraRoll(), CameraYaw(), SwitchCamera()
- added ApplyEntityForce(), ApplyEntityImpulse(), EntityPitch(), EntityRoll(), EntityYaw(), GetEntityAttribute(),
GetEntityMaterial(), SetEntityAttribute(), SetEntityMaterial()
- added LightDiffuseColor(), SpotLightRange(), LightLookAt(), LightPower(), DisableLightShadows()
- added MaterialDepthWrite(), MaterialSelfIlluminationColor(), MaterialShininess(), GetScriptMaterial()
- added BuildMeshShadowVolume(), CreateLine3D(), CreateCube(), CreateSphere(), CreateCylinder(), CreatePlane(), AddSubMesh()
MeshVertexCount(), UpdateMeshBoundingBox(), MeshRadius(), AddMeshVertex(), MeshVertexNormal(), MeshVertexColor()
MeshVertexTextureCoordinate(), AddMeshFace(), FinishMesh(), NormalizeMesh(), SaveMesh(), SetMeshMaterial(), SubMeshCount()
TransformMesh()
- added NodePitch(), NodeRoll(), NodeYaw()

- changed FindString() 'StartPosition' parameter to be optional
- changed WebGadget to use WebKitGtk on Linux
- changed ContainerGadget with #PB_Container_Borderless to no longer add a 2px invisible border on Linux
- changed EntityPhysicBody(), CreateLight(), RenderWorld(), ShowGUI, WorldShadows()

- removed: Get/SetEntityMass(), Get/SetEntityFriction()
- removed: SetMeshData() (temporary, needs to be updated)

IDE:
- added IDE options for commandline project building
- added monitoring of files for changes on disk while they are open in the IDE
- added FilePanel custom implementation with Drag & Drop, Dropdown menu, scrolling also on OSX
- added Diff tool for directories/files
- added Html help viewer for Linux/OSX
- added Help viewer in toolspanel
- new Color Picker tool
- enabled font selection in IDE for OSX
- ProjectPanel now remembers node expanded states

Debugger:
- added maximize button to all debugger windows
- added all IsXxx() and XxxID() functions to the expression parser (for data breakpoints)

Manual:
- The manual is being updated to a new format which more clearly describes
individual function parameters and return values. This is not yet complete,
but will be finished for the final release.
et la liste détaillée des commandes 3D :

Quick help for new 3D commands:
-------------------------------

CameraPitch(#Camera) - Retrieve the pitch of the #Camera.
CameraRoll(#Camera) - Retrieve the roll of the #Camera.
CameraYaw(#Camera) - Retrieve the yaw of the #Camera.
SwitchCamera(#Camera, #NewCamera) - Change the active #Camera with the #NewCamera.

ApplyEntityForce(#Entity, x, y, z []) - Apply a force to #Entity
ApplyEntityImpulse(#Entity, x, y, z []) - Apply a force to #Entity
EntityPhysicBody(#Entity, Type [, Mass [, Restitution, Friction]]) - Change the #Entity physic body
EntityPitch(#Entity) - Return the pitch of the #Entity.
EntityRoll(#Entity) - Return the roll of the #Entity.
EntityYaw(#Entity) - Return the yaw of the #Entity.
GetEntityAttribute(#Entity, Attribute) - Get the #Entity attribute value
GetEntityMaterial(#Entity) - Get the #Entity material
SetEntityAttribute(#Entity, Attribute, Value) - Set an #Entity attribute value
SetEntityMaterial(#Entity, MaterialID) - Set the #Entity material

PointJoint(#Entity, PivotX, PivotY, PivotZ [, #Entity2, PivotX2, PivotY2, PivotZ2])
GetJointAttribute, Long, Long, (#Entity, Attribute)
SetJointAttribute, Long, Long, Float, (#Entity, Attribute, Value)
FreeJoint(#Entity)
HingeJoint(#Entity, PivotX, PivotY, PivotZ, AxisX, AxisY, AxisZ, #Entity2, PivotX2, PivotY2, PivotZ2, AxisX2, AxisY2, AxisZ2)
ConeTwistJoint(#Entity, FxA, FyA, FzA, #Entity2, FxB, FyB, FzB)
SliderJoint(#Entity, FxA, FyA, FzA, #Entity2, FxB, FyB, FzB)

CreateLight(#Light, Color [, x, y, z [, Flags]]) - Create a new #Light.
LightDiffuseColor(#Light, Color)
SpotLightRange(#Light, InnerAngle, OutterAngle [, FallOff])
LightLookAt(#Light, x, y, z)
LightPower(#Light, Power)
DisableLightShadows(#Light, Disable)

MaterialDepthWrite(#Material, Enable) - Enable or disable the #Material depth write.
MaterialSelfIlluminationColor(#Material, Color) - Change the #Material self illumination color.
MaterialShininess(#Material, Shininess) - Change the #Material shininess.
GetScriptMaterial(#Material, Name$) - Get a material defined in scripts files.

BuildMeshShadowVolume(#Mesh)
CreateLine3D(#Mesh, x, y, z, Color, x2, y2, z2, Color2)
CreateCube(#Mesh, Size)
CreateSphere(#Mesh, Radius [Segments, Rings])
CreateCylinder(#Mesh, Radius, Length [, Tesselation, CloseTop, Oblique])
CreatePlane(#Mesh, TileSizeX, TileSizeZ, TileCountX, TileCountZ, TextureRepeatCountX, TextureRepeatCountY)
AddSubMesh()
MeshVertexCount(#Mesh [, SubMesh])
UpdateMeshBoundingBox(#Mesh)
MeshRadius(#Mesh)
AddMeshVertex(x, y, z)
MeshVertexNormal(x, y, z)
MeshVertexColor(Color)
MeshVertexTextureCoordinate(u, v)
AddMeshFace(Vertex1, Vertex2, Vertex3)
FinishMesh()
NormalizeMesh(#Mesh [, SubMesh])
SaveMeshLong, String, (#Mesh, Filename$)
SetMeshMaterial(#Mesh, MaterialID [, SubMesh])
SubMeshCount(#Mesh)
TransformMesh(#Mesh, x, y, z, ScaleX, ScaleY, ScaleZ, RotateX, RotateY, RotateZ [, SubMesh])

NodePitch(#Node) - Return the x position of the #Node.
NodeRoll(#Node) - Return the y position of the #Node.
NodeYaw(#Node) - Return the z position of the #Node.

CreateCompositorEffect(#Effect, CameraID, EffectName$)
CreateRibbonEffect(#Effect, MaterialID, NodeID, NbChains, NbElements, InitialWidth, Length)
FreeEffect(#Effect) - Free the specified #Effect.
HideCompositorEffect(#Effect, State)
CompositorEffectParameter(#Effect, CameraID, EffectName$, DataType, *Data)
IsEffect(#Effect) - Tests if the given '#Effect' is an initialized effect object.
RibbonEffectColor(#Effect, Color, FadeoutColor)

AddStaticGeometryEntity(#StaticGeometry, EntityID, x, y, z [, ScaleX, ScaleY, ScaleZ])
BuildStaticGeometry(#StaticGeometry)
CreateStaticGeometry(#StaticGeometry, Width, Height, Length, EnableShadows)
FreeStaticGeometry(#StaticGeometry) - Free the specified #StaticGeometry.
IsStaticGeometry(#StaticGeometry) - Tests if the given '#StaticGeometry' is an initialized effect object.

RenderWorld([ElapsedPhysicTime]) - Renders the 3D world on the screen.
ShowGUI(Intensity, ShowMouseCursor [#Camera, Enable]) - Shows or hides the GUI
WorldShadows(ShadowType [, Distance]) - Change the shadow handling in this world.
As usual: This is a beta version. Don't be surprised if you find bugs. Please report them all, so we can reach a solid version for the final release.

Have fun with this new version!

The PureBasic Team
  Discussion forum
3 commentaires
  • comtois
    Responsable Purebasic
    Et Fred nous propose 2 exemples pour tester la nouvelle bibliothèque Joint, sauvegardez les codes dans le répertoires sources de PureBasic :

    A point join test:
    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    #CameraSpeed = 5
    
    IncludeFile "Screen3DRequester.pb"
    
    Define.f KeyX, KeyY, MouseX, MouseY
    
    If InitEngine3D()
     
      Add3DArchive("Data", #PB_3DArchive_FileSystem)
     
      InitSprite()
      InitKeyboard()
      InitMouse()
     
      If Screen3DRequester()
       
        ;==================================
        ; create single material
        CreateMaterial(1, LoadTexture(0, "clouds.jpg"))
        MaterialAmbientColor(1, #PB_Material_AmbientColors)
        ;
        CreateMaterial(2, LoadTexture(0, "clouds.jpg"))
        MaterialAmbientColor(2, #PB_Material_AmbientColors)
       
       
        ;==================================
        ; create cube
        CreateCube(1, 1.0)
        cube1=CreateEntity(#PB_Any, MeshID(1), MaterialID(1))
        EntityLocate(cube1, 2,0,0)
        cube2=CreateEntity(#PB_Any, MeshID(1), MaterialID(1))
        EntityLocate(cube2, 2,-3,0)
       
        ;==================================
        ; create sphere
        CreateSphere(2, 0.66)
        sphere=CreateEntity(#PB_Any, MeshID(2), MaterialID(1))
        EntityLocate(sphere, 2,-6,0)
       
       
       
        ; create cube3 (socle)
        CreateCube(2, 10.0)
        socle=CreateEntity(#PB_Any, MeshID(2), MaterialID(2))
        EntityLocate(socle, 5,4,0)
        ScaleEntity(socle, 1,0.1,1)
       
       
        EntityPhysicBody(cube1, #PB_Entity_BoxBody, 1.0)
        EntityPhysicBody(cube2, #PB_Entity_BoxBody, 1.0)
        EntityPhysicBody(sphere, #PB_Entity_SphereBody, 1.0)
        EntityPhysicBody(socle, #PB_Entity_StaticBody)
       
       
        PointJoint(cube1,  0, 7, 0)
        PointJoint(cube2,  0, 0, 0, cube1, 0, -3,0)
        PointJoint(sphere,  0, 2, 0, cube2, 0, -2,0)
       
        ApplyEntityImpulse(cube1,  10, 0, 0)
       
       
        ;==================================
        CreateCamera(0, 0, 0, 100, 100)
        CameraLocate(0,0,2,25)
       
        Repeat
         
          If ExamineKeyboard()
           
            If KeyboardPushed(#PB_Key_O)
              ApplyEntityImpulse(cube2,  0.2, 0, 0)
            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
           
          EndIf
         
          If ExamineMouse()
            MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
            MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
          EndIf
          MoveCamera  (0, KeyX, 0, KeyY)
          RotateCamera(0,  MouseY, MouseX, 0) 
         
          Screen3DEvents()
          ; main render loop
          RenderWorld()
          FlipBuffers()
         
        Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
       
      EndIf
     
    Else
      MessageRequester("Error", "The 3D Engine can't be initialized",0)
    EndIf
    
    End
    and a slider joint test:

    Code :
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    #PB_PointJoint_Tau = 1
    #PB_PointJoint_Damping = 2
    #PB_SliderJoint_LowerLimit = 3
    #PB_SliderJoint_UpperLimit = 4
    #PB_ConeTwistJoint_SwingSpan = 5
    #PB_ConeTwistJoint_SwingSpan2 = 6
    #PB_ConeTwistJoint_TwistSpan = 7
    
    
    #CameraSpeed = 5
    
    IncludeFile "Screen3DRequester.pb"
    
    Define.f KeyX, KeyY, MouseX, MouseY
    
    If InitEngine3D()
     
      Add3DArchive("Data", #PB_3DArchive_FileSystem)
     
      InitSprite()
      InitKeyboard()
      InitMouse()
     
      If Screen3DRequester()
       
        ;==================================
        ; create single material
        CreateMaterial(1, LoadTexture(0, "clouds.jpg"))
        MaterialAmbientColor(1, #PB_Material_AmbientColors)
        ;
        CreateMaterial(2, LoadTexture(0, "clouds.jpg"))
        MaterialAmbientColor(2, #PB_Material_AmbientColors)
       
       
        ;==================================
        ; create cube
        CreateCube(1, 1.0)
        cube1 = CreateEntity(#PB_Any, MeshID(1), MaterialID(1))
        EntityLocate(cube1, -1, -0.5,0)
        RotateEntity(cube1, 0,0,10)
       
        ;==================================
        ; create cube2
        cube2 = CreateEntity(#PB_Any, MeshID(1), MaterialID(2))
        EntityLocate(cube2, 2,0,0)
        RotateEntity(cube2,0,0,10)
       
        ; create cube3 (socle)
        CreateCube(2, 10.0)
        Ground = CreateEntity(#PB_Any, MeshID(2), MaterialID(2))
        EntityLocate(Ground, 5,-8,0)
        ScaleEntity(Ground, 2,0.2,2)
       
       
        EntityPhysicBody(cube1, #PB_Entity_BoxBody, 1.0)
        EntityPhysicBody(cube2, #PB_Entity_BoxBody, 0.0)
       
        SliderJoint(cube1,  0,0.7,0,  cube2,  0,1.1,0)
        SetJointAttribute(cube1, #PB_SliderJoint_LowerLimit, -3)
        SetJointAttribute(cube1, #PB_SliderJoint_UpperLimit, 4)
       
       
        ;==================================
        CreateCamera(0, 0, 0, 100, 100)
        CameraLocate(0,0,2,25)
       
        Repeat
         
          If ExamineKeyboard()
           
            If KeyboardPushed(#PB_Key_O)
              ApplyEntityImpulse(cube1,  0.1, 0, 0)
            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
           
          EndIf
         
          If ExamineMouse()
            MouseX = -(MouseDeltaX()/10)*#CameraSpeed/2
            MouseY = -(MouseDeltaY()/10)*#CameraSpeed/2
          EndIf
          MoveCamera  (0, KeyX, 0, KeyY)
          RotateCamera(0,  MouseY, MouseX, 0) 
         
          Screen3DEvents()
          ; main render loop
          RenderWorld()
          FlipBuffers()
         
        Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
       
      EndIf
     
    Else
      MessageRequester("Error", "The 3D Engine can't be initialized",0)
    EndIf
    
    End
  • comtois
    Responsable Purebasic
    Traduction exprès de djes, merci à lui

    Petite traduction rapide : cette sortie est principalement orientée 3D, avec la mise à jour d'Ogre en version 1.7.0, et le moteur physique d'ODE vers Bullet. En plus de cela, des tonnes de nouvelles bibliothèques et commandes 3D. Les commandes ne sont pas encore traduites, mais il y aura des exemples.

    Un merci spécial à G-Rom et Tmyke pour leur aide sur les nouvelles commandes 3D!

    Note: il peut être nécessaire de faire une mise à jour de DirectX. En cas de problème de DLL, il faut aller là : http://www.microsoft.com/downloads

    Du côté application, la principale mise à jour est la commande CanvasGadget(). C'est une simple surface de dessin qui fournit des événements souris et clavier détaillés pour facilement implémenter des vues de données personnalisées ou des contrôles (le tout multiplateformes) (NdT : par ex une surface de dessin comme dans Paint). Vous pouvez déjà voir ce gadget dans l'IDE : le nouveau panneau de requête de fichiers et le nouveau sélectionneur de couleurs l'utilisent. A part ça, il y a quelques autres nouvelles petites commandes comme des ajouts à la bibliothèque Linkedlist (listes chaînées). Toutes ces nouvelles commandes sont déjà documentées dans le manuel.

    L'IDE a été amélioré, possibilité de construire des projets à partir de la ligne de commande, ou l'option d'être averti quand un fichier a été changé sur le disque. Malheureusement, le framework automation ne sera pas finalisé dans cette release, il n'était pas fini à temps et pas assez prioritaire pour retarder encore la sortie.

    Enfin, la documentation sera bientôt plus précise et lisible quand il s'agira des paramètres de fonctions et des valeurs de retour. C'est un travail en cours qui devrait être terminé pour la sortie finale. Des commentaires sur les nouvelles structures sont bienvenus.
  • blendman
    Nouveau membre du Club
    Très sympa cette nouvelle version, avec les nombreux ajouts 3D.

    On voit bien la puissance du moteur ogre, même avec de simples scènes, c'est classe !
    A ce propos, la version d'ogre utilisée est la 1.7.0 avec purebasic 4.60, donc c'est aussi une bonne chose.