Page 1 of 1

My first 3d model won't load in PB! Please help!!

Posted: Sat Jan 21, 2012 9:17 pm
by tutiplain
Hi all,

I am trying to load a 3d mesh in Purebasic, using the builtin 3d functions. For some reason, it fails to load. Here is my code:

Code: Select all

; space invaders "3d"

InitEngine3D()
InitSprite()
InitKeyboard()

mWnd = OpenWindow(#PB_Any,0,0,1024,768,"Space Invaders 3d", #PB_Window_ScreenCentered| #PB_Window_Normal)

OpenWindowedScreen(WindowID(mWnd),0,0,1024,768,1,0,0,#PB_Screen_SmartSynchronization)

Add3DArchive("C:\pb\mi_space_invaders\",#PB_3DArchive_FileSystem)
Parse3DScripts()

ship_mesh = LoadMesh(#PB_Any,"Cube.mesh")
CallDebugger
ship = CreateEntity(#PB_Any,ship_mesh,#PB_Material_None)
EntityLocate(ship,0,0,0)

cam = CreateCamera(#PB_Any,0,0,1024,768)
CameraLocate(cam,0,2,0)
RotateCamera(cam,90,0,0)

ExamineKeyboard()
Repeat
 ev = WindowEvent()
 ExamineKeyboard()
 
 
 RenderWorld()
 FlipBuffers()
Until ev = #PB_Event_CloseWindow Or KeyboardPushed(#PB_Key_Escape)
 
The Cube.mesh is inside the folder specified in Add3DArchive, as well as the .material file. The model was created as follows:

- Modeled in Blender 2.5 and exported as .dae
- Imported into Blender 2.49 and exported as .mesh.xml with the OGRE exporter plugin
- Converted to .mesh with Ogre Command Line Tools

The code fails in the call to CreateEntity(), saying that "The specified mesh is null". With CallDebugger, I can see that the value of ship_mesh is, indeed, 0 after the call to LoadMesh(). Am I missing something?

Re: My first 3d model won't load in PB! Please help!!

Posted: Sun Jan 22, 2012 2:17 am
by Nituvious
I am not familiar with PB's 3D engine, but maybe try:

Code: Select all

Add3DArchive("C:\pb\mi_space_invaders",#PB_3DArchive_FileSystem)
It might be failing to load the file because the directory is incorrect, or something.

[edit] also you need to give CreateEntity the mesh id.

Code: Select all

ship = CreateEntity(#PB_Any,MeshID(ship_mesh),#PB_Material_None)

Re: My first 3d model won't load in PB! Please help!!

Posted: Sun Jan 22, 2012 7:03 pm
by Fred
You can check the Ogre.log file to see what's wrong with the loading.