LoadMesh() fails

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

LoadMesh() fails

Post by Bananenfreak »

Heyho,

I have a Problem with my new program. Could you please try this code? I think Comodo blocks it again...
Or do I have a real Problem in my code?

Code: Select all

EnableExplicit


Define.f KeyX, KeyY, MouseX, MouseY
Define nx.f, nz.f, Boost.f = 1, Yaw.f, Pitch.f
Define.i Quit, boden, mesh
Define.s path, pathTile
#kam_0 = 0
#window = 0
#plane = 0
#planent = 0

If InitEngine3D()
  
  Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts", #PB_3DArchive_FileSystem)
  Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  OpenWindow(#window, 0, 0, 1800, 1000, "3D-Template", #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(#window), 10, 10, 2000, 2000, 0, 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))
  
  
  path = OpenFileRequester("Choose file to load", "", "OGRE-Mesh (*.mesh)|*.mesh", 0, 0)
  
  pathTile = GetPathPart(path)
  If Not Add3DArchive(Left(pathTile, Len(pathTile) - 1), #PB_3DArchive_FileSystem)
    MessageRequester("Error", "Path can´t be solved!" + Chr(10) + Left(pathTile, Len(pathTile) - 1))
  EndIf
  Parse3DScripts()
  
  mesh = LoadMesh(#PB_Any, GetFilePart(path))
  ;mesh = LoadMesh(#PB_Any, path)
  If Not mesh
    MessageRequester("Error", "This file isn´t a mesh!" + Chr(10) + GetFilePart(path))
  EndIf
  
  
  Repeat
    If ExamineMouse()
      Yaw   = -MouseDeltaX() * 0.05
      Pitch = -MouseDeltaY() * 0.05
    EndIf
    
    If ExamineKeyboard()
      
      If KeyboardPushed(#PB_Key_Up)    
        MoveCamera(0,  0, 0, -2 * Boost)
      ElseIf KeyboardPushed(#PB_Key_Down)
        MoveCamera(0,  0, 0,  2 * Boost)
      EndIf 
      
      If KeyboardPushed(#PB_Key_Left)  
        MoveCamera(0, -2 * Boost, 0, 0) 
      ElseIf KeyboardPushed(#PB_Key_Right)
        MoveCamera(0,  2 * Boost, 0, 0)
      EndIf 
      
    EndIf
    
    RotateCamera(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
Last edited by Bananenfreak on Mon Apr 21, 2014 6:24 pm, edited 1 time in total.
Image
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: LoadMesh() fails

Post by applePi »

Hi Bananenfreak
you forgot to add CreateEntity(...) after LoadMesh(...)
also CreateLight(...)
i depend on the Barrell radius size (=4) "MeshRadius(mesh) line 57" to scale the other meshes so we can see it

Code: Select all

EnableExplicit


Define.f KeyX, KeyY, MouseX, MouseY
Define nx.f, nz.f, Boost.f = 1, Yaw.f, Pitch.f
Define.i Quit, boden, mesh
Define.s path
Define meshsize.f
#kam_0 = 0
#window = 0
#plane = 0
#planent = 1

If InitEngine3D()
  
  Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
  Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Scripts", #PB_3DArchive_FileSystem)
  ;Parse3DScripts()
  
  InitSprite()
  InitKeyboard()
  InitMouse()
  
  ExamineDesktops()
  OpenWindow(#window, 0, 0, DesktopWidth(0), DesktopHeight(0), "3D-Template", #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(#window), 10, 10, DesktopWidth(0), DesktopHeight(0), 0, 10, 10, #PB_Screen_SmartSynchronization)
  
  
  Parse3DScripts()
  WorldShadows(#PB_Shadow_TextureAdditive, 200, RGB(255 * 0.2, 255 * 0.2, 255 * 0.2), 4096)
  
  CreateLight(33,RGB(255,255,255),-100,40,30)
  AmbientColor(RGB(255,255,255))
  ;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, -10, #PB_Absolute)
  CameraLookAt(#kam_0, 20, 0, 20)
  CameraRange (#kam_0, 2, 5000)
  CameraFOV   (#kam_0, 90)
  CameraBackColor(#kam_0, RGB(0, 0, 0))
  
  
  path = OpenFileRequester("Choose file to load", "", "OGRE-Mesh (*.mesh)|*.mesh", 0, 0)
  
  If Not Add3DArchive(GetPathPart(path), #PB_3DArchive_FileSystem)
    MessageRequester("Error", "Path can´t be solved!" + Chr(10) + GetPathPart(path))
  EndIf
  
  
  mesh = LoadMesh(#PB_Any, GetFilePart(path))
  meshsize.f = MeshRadius(mesh)
  Debug "MeshRadius = " + Str(meshsize)
  CreateEntity(23,MeshID(mesh), #PB_Material_None,0,10,0) 
  ScaleEntity(23,4/meshsize,4/meshsize,4/meshsize)
  
  If Not mesh
    MessageRequester("Error", "This file isn´t a mesh!" + Chr(10) + GetFilePart(path))
  EndIf
  
  
  Repeat
    If ExamineMouse()
      Yaw   = -MouseDeltaX() * 0.05
      Pitch = -MouseDeltaY() * 0.05
    EndIf
    
    If ExamineKeyboard()
      
      If KeyboardPushed(#PB_Key_Up)    
        MoveCamera(0,  0, 0, -0.3 * Boost)
      ElseIf KeyboardPushed(#PB_Key_Down)
        MoveCamera(0,  0, 0,  0.3 * Boost)
      EndIf 
      
      If KeyboardPushed(#PB_Key_Left)  
        MoveCamera(0, -0.3 * Boost, 0, 0) 
      ElseIf KeyboardPushed(#PB_Key_Right)
        MoveCamera(0,  0.3 * Boost, 0, 0)
      EndIf 
      
    EndIf

    RotateCamera(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
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: LoadMesh() fails

Post by Bananenfreak »

No, I mean on my PC my program throws out an Error.

Code: Select all

MessageRequester("Error", "This file isn´t a mesh!" + Chr(10) + GetFilePart(path))
(In your code, too)

But what I´ve done wrong?

I think I found the solution. Wait a Minute with your answers.
Edit: No, this wasn´t the answer. I updated my code in the first post.
Image
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: LoadMesh() fails

Post by Samuel »

Everything seems to work fine here. Does your Ogre log give you any errors?
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: LoadMesh() fails

Post by Bananenfreak »

Hmm, I didn't read it. So later this day I will read it...

@Samuel: My program (1. Post) throws out no error on your computer?
I think Comodo is evil...

EDIT:
I found something, but I don´t know what it mean. 3DArchive was added succesfully...
19:19:13: Added resource location 'D:\...\Mesh' of type 'FileSystem' to resource group 'General'
19:19:13: Mesh: Loading Linde_0_4_Ast_1.mesh.
19:19:13: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource Linde_0_4_Ast_1.mesh in resource group General or any other group. in ResourceGroupManager::openResource at OgreResourceGroupManager.cpp (line 756)
Image
User avatar
Samuel
Enthusiast
Enthusiast
Posts: 756
Joined: Sun Jul 29, 2012 10:33 pm
Location: United States

Re: LoadMesh() fails

Post by Samuel »

Bananenfreak wrote: @Samuel: My program (1. Post) throws out no error on your computer?
Yes, your code works fine for me. I haven't tested applePi's code yet.
Bananenfreak wrote: I found something, but I don´t know what it mean. 3DArchive was added succesfully...
19:19:13: Added resource location 'D:\...\Mesh' of type 'FileSystem' to resource group 'General'
19:19:13: Mesh: Loading Linde_0_4_Ast_1.mesh.
19:19:13: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource Linde_0_4_Ast_1.mesh in resource group General or any other group. in ResourceGroupManager::openResource at OgreResourceGroupManager.cpp (line 756)
The OGRE EXCEPTION is just reporting that it can't find a mesh under that name.
Have you debugged the path after the File Requester returns? Maybe Comodo is somehow messing up the path.

Also does your mesh load without using the OpenFileRequester?
If it doesn't then maybe there is something wrong with your mesh.

Code: Select all

If InitEngine3D()
 
  InitSprite()
  InitKeyboard()
  InitMouse()
 
  ExamineDesktops()
  OpenWindow(#window, 0, 0, DesktopWidth(0), DesktopHeight(0), "3D-Template", #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(#window), 10, 10, DesktopWidth(0), DesktopHeight(0), 0, 10, 10, #PB_Screen_SmartSynchronization)
 
  ;# Set Path
  Add3DArchive("C:/PathToMesh", #PB_3DArchive_FileSystem)
  Parse3DScripts()

  ;-Camera
  CreateCamera(0, 0, 0, 100, 100)
  MoveCamera(0, 0, 0, 50, #PB_Absolute)
  CameraLookAt(0, 0, 0, 0)
  CameraBackColor(0, RGB(0, 0, 0))
 
  CreateLight(0, RGB(255,255,255), 0, 100, 50)

  mesh = LoadMesh(#PB_Any, "Linde_0_4_Ast_1.mesh")
  CreateEntity(23, MeshID(mesh), #PB_Material_None, 0, 0, 0)

  Repeat

    RenderWorld()
    FlipBuffers()
  Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
 
Else
  MessageRequester("Error", "The 3D Engine can't be initialized", 0)
EndIf

End
User avatar
Bananenfreak
Enthusiast
Enthusiast
Posts: 519
Joined: Mon Apr 15, 2013 12:22 pm

Re: LoadMesh() fails

Post by Bananenfreak »

Mysterious...

If path has additional Character like this:
E:\PathToMeshÜ
Program don´t find my meshfile.

But if I cancel those characters, so it Looks like:
E:\PathToMesh
Everything is fine, my mesh will be loaded from the engine.

So, in my prefered language german, there are in many words ad. chars (~half of my pc can´t get access with OGRE caused of additional chars).

So there´s a bug with Add3DArchive() and additional Chars like:
ÄÖÜß
So, admin, please move this Topic to Bugs-Windows (Or should I create a new Topic?).
Image
applePi
Addict
Addict
Posts: 1404
Joined: Sun Jun 25, 2006 7:28 pm

Re: LoadMesh() fails

Post by applePi »

it is may be Ogre itself can't load mesh files which assigned unicode names, i have changed the mesh file to a german name and it fails to load it even after setting the compiler options and ide to unicode. my windows is xp english and the german names displayed correctly in my browser
the same i have tried show mesh utility http://garr.dl.sourceforge.net/project/ ... -win32.exe
also it fails to load a mesh with none english characters it its name.
Edit: some useful talk : http://www.ogre3d.org/forums/viewtopic.php?f=2&t=76191
Post Reply