OpenB3D 3D DLL framework include file for PureBasic

Share your advanced PureBasic knowledge/code with the community.
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Re: OpenB3D 3D DLL framework include file for PureBasic

Post by skinkairewalker »

hello guys, I would like to know how I do to animate a model, I'm using > OB3D_LoadAnimMesh and OB3D_Animate(1,1,0,0) but dont works ...
Can anyone give me a light ?
Axeman
User
User
Posts: 89
Joined: Mon Nov 03, 2003 5:34 am

Re: OpenB3D 3D DLL framework include file for PureBasic

Post by Axeman »

OpenB3D is based on Blitz3D and uses most of the same commands. You can find Blitz3D along with usage docs and examples at the links below.

https://kippykip.com/b3ddocs/commands/index.htm | https://blitzresearch.itch.io/blitz3d | https://nitrologic.itch.io/blitz3d
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Re: OpenB3D 3D DLL framework include file for PureBasic

Post by skinkairewalker »

using the example in this documentation https://kippykip.com/b3ddocs/commands/3 ... imMesh.htm, the application runs and crashes... does anyone know what i'm doing wrong?

Code: Select all

IncludeFile "openb3d.pb"

UseJPEGImageDecoder()
UseJPEG2000ImageDecoder()

; === DEMO ===
#MAIN_WINDOW = 0
#OPENGL_SCREEN = 0
#PREVIEW_SIZEW =1024
#PREVIEW_SIZEH =600
#Menu_Event_CloseWindow = 0

OpenWindow( #MAIN_WINDOW, 0, 0, #PREVIEW_SIZEW, #PREVIEW_SIZEH, "Purebasic OpenB3D",
            #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget)

;OpenWindowedScreen( WindowID( #MAIN_WINDOW ), 0, 0, #PREVIEW_SIZE, #PREVIEW_SIZE )
OpenGLGadget( #OPENGL_SCREEN, 0, 0, #PREVIEW_SIZEW, #PREVIEW_SIZEH )

OB3D_Graphics3D( #PREVIEW_SIZEW, #PREVIEW_SIZEH, 0, 2, 60 )
OB3D_AntiAlias( 1 ) ; don't work
; *texture = OB3D_LoadTexture(#PB_Compiler_Home+"Examples\3D\Data\Textures\Dirt.jpg" ) 
*texture = OB3D_LoadTexture(GetCurrentDirectory()+"data/Gargoyle.bmp" ) 

*camera = OB3D_CreateCamera()
OB3D_CameraClsColor( *camera, 150.0, 150.0, 255.0 )
OB3D_MoveEntity( *camera, 0.0, 1, -200.0 )
OB3D_RotateEntity( *camera, -10, 0, 0 )

*light = OB3D_CreateLight()
OB3D_MoveEntity( *light, 0.0, -10.0, 0.0 )
*light2 = OB3D_CreateLight()
OB3D_MoveEntity( *light2, 5.0, 0.0, 0.0 )
*platform = OB3D_LoadAnimMesh("data/Gargoyle.md2")
OB3D_EntityTexture( *platform, *texture)
OB3D_RotateEntity( *platform, 80.0, 0.0, 0.0 )
OB3D_MoveEntity( *platform, 10.0, 0.0, 50.0 )


AddKeyboardShortcut( #MAIN_WINDOW, #PB_Shortcut_Escape, #Menu_Event_CloseWindow )
; OB3D_PositionMesh(*platform, 0, -5, 0)

OB3D_Animate(*platform,2)

;Debug OB3D_AnimLength(*platform)

OB3D_UpdateWorld()
OB3D_RenderWorld()
;FlipBuffers() ; Use for 'OpenWindowedScreen'.
SetGadgetAttribute( #OPENGL_SCREEN, #PB_OpenGL_FlipBuffers, #True ) ; Use for 'OpenGLGadget'.

Repeat
  Select WaitWindowEvent(1)
    Case #PB_Event_Menu
      If EventMenu() = #Menu_Event_CloseWindow : Break : EndIf
    Case #PB_Event_CloseWindow
      Break
  EndSelect
  
  OB3D_UpdateWorld()
  OB3D_RenderWorld()
  FlipBuffers() ; Use for 'OpenWindowedScreen'.
;   SetGadgetAttribute( #OPENGL_SCREEN, #PB_OpenGL_FlipBuffers, #True ) ; Use for 'OpenGLGadget'.
  
ForEver
EndProgram()

benubi
Enthusiast
Enthusiast
Posts: 113
Joined: Tue Mar 29, 2005 4:01 pm

Re: OpenB3D 3D DLL framework include file for PureBasic

Post by benubi »

perhaps check your available screen resolutions, and correct the two lines

#PREVIEW_SIZEW =1024
#PREVIEW_SIZEH =600

to:

#PREVIEW_SIZEW =1024
#PREVIEW_SIZEH =768

1024 x 600 is an uncommon resolution for desktop computers and will probably not be supported by your graphics card. (800x600 may work too, tho, but I never used OB3D).
Axeman
User
User
Posts: 89
Joined: Mon Nov 03, 2003 5:34 am

Re: OpenB3D 3D DLL framework include file for PureBasic

Post by Axeman »

The screen resolution shouldn't be an issue, as you are using windowed mode which doesn't have the limitations that fullscreen has.

Try putting some numbered 'Debug' statements in there to see if you can identify the line that is causing the crash.
xperience2003
Enthusiast
Enthusiast
Posts: 111
Joined: Tue Oct 05, 2004 9:05 pm
Location: germany
Contact:

Re: OpenB3D 3D DLL framework include file for PureBasic

Post by xperience2003 »

from where can i get the this OpenB3D framework ? i found just import for freebasic
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Re: OpenB3D 3D DLL framework include file for PureBasic

Post by skinkairewalker »

Why is there a black area around the view?
screenshot : https://prnt.sc/Pb6wjO9vUPO_

code :

Code: Select all

IncludeFile "openb3d.pb"

InitSprite()
UseJPEGImageDecoder()
UseJPEG2000ImageDecoder()

; === DEMO ===
#MAIN_WINDOW = 0
#OPENGL_SCREEN = 0
#PREVIEW_SIZEW =1024
#PREVIEW_SIZEH =600
#Menu_Event_CloseWindow = 0

OpenWindow( #MAIN_WINDOW, 0, 0, #PREVIEW_SIZEW, #PREVIEW_SIZEH, "Purebasic OpenB3D",
            #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget)

;OpenWindowedScreen( WindowID( #MAIN_WINDOW ), 0, 0, #PREVIEW_SIZE, #PREVIEW_SIZE )
OpenGLGadget( #OPENGL_SCREEN, 0, 0, #PREVIEW_SIZEW, #PREVIEW_SIZEH )

OB3D_Graphics3D( #PREVIEW_SIZEW, #PREVIEW_SIZEH, 0, 2, 60 )
OB3D_AntiAlias( 1 ) ; don't work
; *texture = OB3D_LoadTexture(#PB_Compiler_Home+"Examples\3D\Data\Textures\Dirt.jpg" ) 
*texture = OB3D_LoadTexture(GetCurrentDirectory()+"data/dragon_gold.jpg" ) 

*camera = OB3D_CreateCamera()
OB3D_CameraClsColor( *camera, 150.0, 150.0, 255.0 )
OB3D_MoveEntity( *camera, 0.0, 1, -200.0 )
OB3D_RotateEntity( *camera, -10, 0, 0 )

*light = OB3D_CreateLight()
OB3D_MoveEntity( *light, 0.0, -10.0, 0.0 )
*light2 = OB3D_CreateLight()
OB3D_MoveEntity( *light2, 5.0, 0.0, 0.0 )
*platform = OB3D_LoadAnimMesh("data/Dragon.b3d")
OB3D_EntityTexture( *platform, *texture)
OB3D_RotateEntity( *platform, 80.0, 0.0, 0.0 )
OB3D_MoveEntity( *platform, 10.0, 0.0, 50.0 )


AddKeyboardShortcut( #MAIN_WINDOW, #PB_Shortcut_Escape, #Menu_Event_CloseWindow )
; OB3D_PositionMesh(*platform, 0, -5, 0)

OB3D_Animate(*platform,2)

;Debug OB3D_AnimLength(*platform)

OB3D_UpdateWorld()
OB3D_RenderWorld()
;FlipBuffers() ; Use for 'OpenWindowedScreen'.
SetGadgetAttribute( #OPENGL_SCREEN, #PB_OpenGL_FlipBuffers, #True ) ; Use for 'OpenGLGadget'.

Repeat
  Select WaitWindowEvent(1)
    Case #PB_Event_Menu
      If EventMenu() = #Menu_Event_CloseWindow : Break : EndIf
    Case #PB_Event_CloseWindow
      Break
  EndSelect
  
  OB3D_UpdateWorld()
  OB3D_RenderWorld()
 ;FlipBuffers() ; Use for 'OpenWindowedScreen'.
   SetGadgetAttribute( #OPENGL_SCREEN, #PB_OpenGL_FlipBuffers, #True ) ; Use for 'OpenGLGadget'.
  
ForEver
EndProgram()


User avatar
Kuron
Addict
Addict
Posts: 1626
Joined: Sat Oct 17, 2009 10:51 pm
Location: Pacific Northwest

Re: OpenB3D 3D DLL framework include file for PureBasic

Post by Kuron »

I will likely delve into this, but also want to ask has anybody written includes or wrappers for the B3D SDK?
Best wishes to the PB community. Thank you for the memories. ♥️
User avatar
skinkairewalker
Enthusiast
Enthusiast
Posts: 627
Joined: Fri Dec 04, 2015 9:26 pm

Re: OpenB3D 3D DLL framework include file for PureBasic

Post by skinkairewalker »

this is my working code...

Code: Select all

IncludeFile "openb3d.pb"

InitSprite()
UseJPEGImageDecoder()
UseJPEG2000ImageDecoder()
ExamineDesktops()

; === DEMO ===
#MAIN_WINDOW = 0
#OPENGL_SCREEN = 0
#PREVIEW_SIZEW =1024
#PREVIEW_SIZEH =600
#Menu_Event_CloseWindow = 0
Global DeskWidth.i = DesktopWidth(0)
Global DeskHeight.i= DesktopHeight(0)

OpenWindow( #MAIN_WINDOW, 0, 0, #PREVIEW_SIZEW, #PREVIEW_SIZEH, "Purebasic OpenB3D",
            #PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_MaximizeGadget|#PB_Window_MinimizeGadget)

;OpenWindowedScreen( WindowID( #MAIN_WINDOW ), 0, 0, #PREVIEW_SIZE, #PREVIEW_SIZE )
OpenGLGadget( #OPENGL_SCREEN, 0, 0, WindowWidth(0), WindowHeight(0) )

Debug DeskWidth
Debug DeskHeight
Debug WindowWidth(0)
Debug WindowHeight(0)

OB3D_Graphics3D( 1282, 750, 0, 2, 60 )
OB3D_AntiAlias( 1 ) ; don't work
; *texture = OB3D_LoadTexture(#PB_Compiler_Home+"Examples\3D\Data\Textures\Dirt.jpg" ) 
*texture = OB3D_LoadTexture(GetCurrentDirectory()+"data/dragon_gold.jpg" ) 

*camera = OB3D_CreateCamera()
OB3D_CameraClsColor( *camera, 400.0, 400.0, 255.0 )
OB3D_MoveEntity( *camera, 0.0, 1, -300.0 )
OB3D_RotateEntity( *camera, -20, -20, -50 )

*light = OB3D_CreateLight()
OB3D_MoveEntity( *light, 0.0, -10.0, 0.0 )
*light2 = OB3D_CreateLight()
OB3D_MoveEntity( *light2, 5.0, 0.0, 0.0 )
*platform = OB3D_LoadAnimMesh("data/Dragon.b3d")
OB3D_EntityTexture( *platform, *texture)
OB3D_RotateEntity( *platform, 80.0, 0.0, 0.0 )
OB3D_MoveEntity( *platform, 10.0, 0.0, 50.0 )


AddKeyboardShortcut( #MAIN_WINDOW, #PB_Shortcut_Escape, #Menu_Event_CloseWindow )
; OB3D_PositionMesh(*platform, 0, -5, 0)

OB3D_Animate(*platform,2)

;Debug OB3D_AnimLength(*platform)

OB3D_UpdateWorld()
OB3D_RenderWorld()
;FlipBuffers() ; Use for 'OpenWindowedScreen'.
SetGadgetAttribute( #OPENGL_SCREEN, #PB_OpenGL_FlipBuffers, #True ) ; Use for 'OpenGLGadget'.

Repeat
  Select WaitWindowEvent(1)
    Case #PB_Event_Menu
      If EventMenu() = #Menu_Event_CloseWindow : Break : EndIf
    Case #PB_Event_CloseWindow
      Break
  EndSelect
  
  OB3D_UpdateWorld()
  OB3D_RenderWorld()
 ;FlipBuffers() ; Use for 'OpenWindowedScreen'.
   SetGadgetAttribute( #OPENGL_SCREEN, #PB_OpenGL_FlipBuffers, #True ) ; Use for 'OpenGLGadget'.
  
ForEver
EndProgram()

I noticed some "weird" patterns, the X,Y reference point is at the bottom left (the size reference has to be based on the bottom left corner).
Post Reply