have a way to import .fbx , .x , .b3d , .3ds in pb ?

Everything related to 3D programming
User avatar
skinkairewalker
Addict
Addict
Posts: 807
Joined: Fri Dec 04, 2015 9:26 pm

have a way to import .fbx , .x , .b3d , .3ds in pb ?

Post by skinkairewalker »

hi , how can i import to pb , another formats 3D ?
like fbx , x , b3d , 3ds and others in PureBasic ?
box_80
Enthusiast
Enthusiast
Posts: 117
Joined: Mon Sep 03, 2012 8:52 pm

Re: have a way to import .fbx , .x , .b3d , .3ds in pb ?

Post by box_80 »

Pure Basic's Ogre3D Library use only ogre format, so other formats need a converter.
MPZ's MP3D Library use X, B3D, 3DS
There outdated wrappers for other 3D engines for Pure Basic.
User avatar
skinkairewalker
Addict
Addict
Posts: 807
Joined: Fri Dec 04, 2015 9:26 pm

Re: have a way to import .fbx , .x , .b3d , .3ds in pb ?

Post by skinkairewalker »

how i use this library with PureBasic ?
can you send a example code ?
box_80
Enthusiast
Enthusiast
Posts: 117
Joined: Mon Sep 03, 2012 8:52 pm

Re: have a way to import .fbx , .x , .b3d , .3ds in pb ?

Post by box_80 »

Run any of the files in the 3D folder of your Purebasic directory, like Mesh.pb, Light.pb, etc. Many examples in there. Below is the Mesh example.

Code: Select all

;
; ------------------------------------------------------------
;
;   PureBasic - Entity
;
;    (c) Fantaisie Software
;
; ------------------------------------------------------------
;

#CameraSpeed = 1

IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"

Define.f KeyX, KeyY, MouseX, MouseY, RollZ


If InitEngine3D()
  
  Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Models", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "examples/3d/Data/Packs/skybox.zip", #PB_3DArchive_Zip)
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  If Screen3DRequester()
    
    LoadMesh(0, "robot.mesh")
    
    CreateMaterial(0, LoadTexture(0, "clouds.jpg"))
    CopyMaterial(0, 1)
    CreateMaterial(2, LoadTexture(2, "r2skin.jpg"))
    MaterialShadingMode(0, #PB_Material_Wireframe)
    
    CreateEntity(0, MeshID(0), MaterialID(0))
    CreateEntity(1, MeshID(0), MaterialID(1), -60, 0, 0)
    CreateEntity(2, MeshID(0), MaterialID(2),  60, 0, 0)
    
    StartEntityAnimation(0, "Walk")
    
    EntityRenderMode(0, #PB_Entity_DisplaySkeleton)
    
    SkyBox("stevecube.jpg")
    
    CreateCamera(0, 0, 0, 100, 100)
    MoveCamera(0, 0, 40, 150, #PB_Absolute)
    
    Repeat
      Screen3DEvents()
      
      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
      
      If ExamineKeyboard()
        
        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
      
      RotateEntity(1, 0, 1, 0, #PB_Relative)
      RotateEntity(2, 0, 1, 0, #PB_Relative)
      
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      MoveCamera  (0, KeyX, 0, KeyY)
      
      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
User avatar
skinkairewalker
Addict
Addict
Posts: 807
Joined: Fri Dec 04, 2015 9:26 pm

Re: have a way to import .fbx , .x , .b3d , .3ds in pb ?

Post by skinkairewalker »

Alexi wrote:Which modelling software do you use? 3DS, C4D, Blender all support a format to export to OGRE, last one is free.

i donwload blender but i dont see where i export in . mesh xD , how i export . mesh in blender ?
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: have a way to import .fbx , .x , .b3d , .3ds in pb ?

Post by applePi »

skinkairewalker writes: how i export . mesh in blender ?
it is easier to export as obj file, then convert it to mesh with a tool OgreAssimpConverter:
download the file OgreAssimpConverter.zip from here (requiers the VC++2010 runtime):
http://www.purebasic.fr/english/viewtop ... 22#p401729

and any obj, 3ds, may be other formats, suppose cat.obj
write from command prompt OgreAssimpConverter "cat.obj"
and it will produce cat.mesh

as a successful example look this thread http://purebasic.fr/english/viewtopic.p ... =cathedral
the cathedral sibenik.obj converted to sibenik.mesh with suitable mapping of textures to the mesh.
here is the converted file instead of the 2shared.com link there:
http://wikisend.com/download/341904/sibenik3.rar
Post Reply