Loading Meshes in "/"-Archive

Everything related to 3D programming
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Loading Meshes in "/"-Archive

Post by Bananenfreak »

Heyho friends,

I´ve got an Problem. In old Versions of PB (before 5.31) I was able to add 3DArchives with the path "/" and so I have placed my meshes in one Folder with the executable. Now I can use Add3DArchive("/", #PB_3DArchive_FileSystem) without Problems, but I can´t load meshes. Every time I get a 0. If I don´t use relative paths it works and my program loads the mesh correct.
Even my older codes aren´t work if they use Add3DArchive("/", #PB_3DArchive_FileSystem).

What am I doing wrong? Is it a fault by me or just a new bug?

Could you please test the code above? Perhaps this issue is related to my PC...
You have to put a meshfile next to your compilated exe, so use "Create temporary exe in sourcecode Directory" (I don´t know how this is called in the english Version) if you want it simple. Rename the LoadMesh() and there you go:

Code: Select all

;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
;>>                             >>
;>>  Name: /-Test               >>
;>>                             >>
;>>  Author: Bananenfreak       >>
;>>                             >>
;>>  Date: 04.07.2015           >>
;>>                             >>
;>>  OS: Windows                >>
;>>                             >>
;>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
EnableExplicit


Define.f KeyX, KeyY, MouseX, MouseY
Define nx.f, nz.f, Boost.f = 1, Yaw.f, Pitch.f
Define.i Quit, boden
#kam_0 = 3
#window = 2
#plane = 4
#planent = 5

If InitEngine3D(#PB_Engine3D_EnableCG)
  
  Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts", #PB_3DArchive_FileSystem)
  ;Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Models", #PB_3DArchive_FileSystem)
  Debug "Current Directory:" + GetCurrentDirectory()
  Debug "3D_Archive:" + Add3DArchive("/", #PB_3DArchive_FileSystem)
  Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  OpenWindow(#window, 0, 0, 1800, 1000, "/-Test", #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(#window), 10, 10, 2000, 2000, 1, 10, 10, #PB_Screen_SmartSynchronization)
  
  WorldShadows(#PB_Shadow_TextureAdditive, 200, RGB(255 * 0.2, 255 * 0.2, 255 * 0.2), 4096)
  
  AmbientColor(RGB(255 * 0.2, 255 * 0.2, 255 * 0.2))
  
  CreatePlane(#plane, 100, 100, 100, 100, 100, 100)
  boden = GetScriptMaterial(#PB_Any, "Scene/GroundBlend")
  CreateEntity(#planent, MeshID(#plane), MaterialID(boden), 0, 0, 0)
  
  ;-Camera
  CreateCamera(#kam_0, 0, 0, 100, 100)
  MoveCamera(#kam_0, 0, 20, 0, #PB_Absolute)
  CameraLookAt(#kam_0, 20, 0, 20)
  CameraRange (#kam_0, 2, 5000)
  CameraFOV   (#kam_0, 90)
  CameraBackColor(#kam_0, RGB(0, 0, 0))
  
  Debug "Mesh"+LoadMesh(#PB_Any, "AKM.mesh")             ;-<----- Rename here
  ;CreateEntity(#PB_Any, MeshID(LoadMesh(#PB_Any, "Linde_0_3_Ast_0.mesh")), #PB_Material_None, 0, 5, 0)
  
  Repeat
    Repeat
    Until WindowEvent() = 0
    
    If ExamineMouse()
      Yaw   = -MouseDeltaX() * 0.05
      Pitch = -MouseDeltaY() * 0.05
    EndIf
    
    If ExamineKeyboard()
      
      If KeyboardPushed(#PB_Key_Up)    
        MoveCamera(#kam_0, 0, 0, -Boost)
      ElseIf KeyboardPushed(#PB_Key_Down)
        MoveCamera(#kam_0,  0, 0,  1 * Boost)
      EndIf 
      
      If KeyboardPushed(#PB_Key_Left)  
        MoveCamera(#kam_0, -1 * Boost, 0, 0) 
      ElseIf KeyboardPushed(#PB_Key_Right)
        MoveCamera(#kam_0,  1 * Boost, 0, 0)
      EndIf 
      
    EndIf
    
    RotateCamera(#kam_0, Pitch, Yaw, 0, #PB_Relative)
    
    RenderWorld()
    FlipBuffers()
  Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
  
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf

End
If you find the Problem in my code, please let me know. Thank you :)
Image
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: Loading Meshes in "/"-Archive

Post by applePi »

Hi Bananenfreak, i have noticed that before. as an example download and run this PerPixel Shader example http://www.purebasic.fr/english/viewtop ... 36&t=57778
it will throw error "The specidied texture not initialized", it uses this line
Add3DArchive("/", #PB_3DArchive_FileSystem)
change "/" to "." and it will work, the "." refer to the same folder of the code and you will be able to load models, textures, material scripts located in that folder .
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: Loading Meshes in "/"-Archive

Post by Bananenfreak »

Good to know, thank you ApplePi :)
Image
Post Reply