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

Just starting out? Need help? Post your questions and find answers here.
tutiplain
User
User
Posts: 43
Joined: Wed Jun 30, 2010 3:00 am

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

Post 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?
Nituvious
Addict
Addict
Posts: 1032
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

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

Post 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)
▓▓▓▓▓▒▒▒▒▒░░░░░
Fred
Administrator
Administrator
Posts: 18499
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

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

Post by Fred »

You can check the Ogre.log file to see what's wrong with the loading.
Post Reply