When trying to get the returned value of this the exe crashes, or if you don't try and use the return value the program will keep running but not show the 3d node.
Code: Select all
//Add an animated scene node
API int CALLCONV pb_CreateAnimatedNode(char * fileName,int meshID,float scaleX,float scaleY,float scaleZ,int isLighting)
{
IAnimatedMeshSceneNode *node=pb_scene->addAnimatedMeshSceneNode(pb_scene->getMesh(fileName),0,meshID,vector3df(0,0,0),vector3df(0,0,0),vector3df(scaleX,scaleY,scaleZ));
node->setMaterialFlag(video::EMF_LIGHTING, pb_intToBool(isLighting));
return node->getID();
}
Yet this works fine and the returned value is correct and does not crash the exe:
Code: Select all
ProcedureCDLL EventHandler(*EventData.I3D_GUI_EVENT)
If *EventData\eventType=#I3D_GUIEVENT_BUTTON_CLICKED
LastGuiID=*EventData\guiID
EndIf
EndProcedure
Procedure HandleGUIEvent(guiID.l)
If guiID=102
pb_Node_SetMaterialFlag_(1,#I3D_MATERIALFLAG_WIREFRAME,1)
EndIf
EndProcedure
ShipData.I3D_NODEDATA
If pb_Initialize3D_(#I3D_DRIVER_OPENGL, 640,480,32,0,1,@EventHandler())
;set startup values
InitKeyboard()
pb_SetShadowColor_(255,0,0,0)
pb_SetBackgroundColor_(155,90,90,90)
pb_SetWindowCaption_("Test PB_Irrlicht")
pb_GUI_SetFont_("./fontcourier.bmp")
pb_LoadMesh_("./ship1.ms3d")
pb_LoadTexture_("./ship1.bmp")
pb_CreateAnimatedNode_("./ship1.ms3d",1,1,1,1,1)
pb_Node_SetMaterialType_(1,#I3D_MATERIALTYPE_SPHERE_MAP)
pb_Node_SetTexture_("./ship1.bmp",1,0)
pb_CreateDynamicLight_(1,5,5,5,100,255,255,255,100)
pb_Camera_SetPosition_(20,50,20)
;create GUI
EditBox1.l = pb_GUI_CreateEditBox_("Edit box sample",101,100,100,250,150,1)
Button1.l = pb_GUI_CreateButton_("Wireframe",102,400,100,500,150)
Static1.l = pb_GUI_CreateStaticText_("Static text is fun!",103,250,250,400,300,0,0)
MsgBox.l = pb_GUI_CreateMessageBox_("Test MsgBox","Testing 1 2 3",104,1,#I3D_GUI_MSGBOX_OK + #I3D_GUI_MSGBOX_CANCEL)
lastFPS.l=0
While pb_Running_()
pb_Camera_PointAtNode_(1)
;Render the scene
pb_BeginRender_(1,1)
pb_Draw2DText_("./fontcourier.bmp",10,10,"Hello and welcome to PB_Irrlicht by dracflamloc!",255,255,255,255,0)
pb_Draw2DText_("./fontcourier.bmp",10,30,"http://www.dracsoft.com/",255,255,255,255,0)
pb_Draw2DText_("./fontcourier.bmp",10,50,"X: " + Str(ShipData\xPos),255,255,255,255,0)
pb_Draw2DText_("./fontcourier.bmp",10,70,"Z: " + Str(ShipData\zPos),255,255,255,255,0)
pb_DrawScene_()
pb_DrawGUI_()
pb_EndRender_()
;check fps and update titlebar
If lastFPS<>pb_GetFPS_()
lastFPS = pb_GetFPS_()
pb_SetWindowCaption_("Test PB_Irrlicht - " + Str(lastFPS) + " FPS")
EndIf
;rotate object
pb_Node_GetData_(1,@ShipData)
pb_Node_SetRotation_(1,ShipData\xRot+0.05,ShipData\yRot+0.05,ShipData\zRot-0.05)
;check keypress
ExamineKeyboard()
If KeyboardReleased(#PB_Key_Escape)
pb_Close3D_()
ElseIf KeyboardPushed(#PB_Key_Left)
pb_Node_GetData_(1,@ShipData)
pb_Node_SetPosition_(1,ShipData\xPos - 0.05,ShipData\yPos,ShipData\zPos)
ElseIf KeyboardPushed(#PB_Key_Right)
pb_Node_GetData_(1,@ShipData)
pb_Node_SetPosition_(1,ShipData\xPos + 0.05,ShipData\yPos,ShipData\zPos)
ElseIf KeyboardPushed(#PB_Key_Up)
pb_Node_GetData_(1,@ShipData)
pb_Node_SetPosition_(1,ShipData\xPos,ShipData\yPos,ShipData\zPos - 0.05)
ElseIf KeyboardPushed(#PB_Key_Down)
pb_Node_GetData_(1,@ShipData)
pb_Node_SetPosition_(1,ShipData\xPos,ShipData\yPos,ShipData\zPos + 0.05)
EndIf
;for now use the global to handle the gui event
HandleGUIEvent(LastGuiID)
Wend
Else
MessageRequester("Error","Could not initialize the 3D device.")
EndIf
pb_DoCleanUp_()
End