J'ai créé un objet avec 3 textures différentes sous Sketchup, je l'ai exporté en .obj, puis converti en .mesh et .material avec OgreAssimpConverter.
J'ai tenté de charger cet objet dans PB, mais je me heurte à plusieurs difficultés, notamment avec le chemin des différents fichiers.
Au final, mon objet (la maison) est tout noir.
Quelqu'un saurait-il m'expliquer ce que je fais de mal ? Ou plutôt ce que je ne fais pas de bien ?
A noter que pour mon objet velo.mesh :
Si je ne mets pas le chemin relatif vers la texture velo.png, PB ne la trouve pas !
Si je mets le chemin relatif vers l'objet velo.mesh, PB ne le trouve pas !
C'est à en perdre la tête !
Et pour mon objet maison :
le log d'Ogre semble indiquer que 2 des 3 textures sont chargées avec succès. Mais pourtant aucune n'apparaît.
J'ai lu quelque-part qu'il fallait indiquer #PB_Material_None dans createEntity si le .mesh avait un .material associé. C'est vrai ? parce que sinon je ne vois pas comment faire autrement.
Voilà, le code et l'ensemble des fichiers sont dans l'archive ici : http://lecartablededudule.pagesperso-or ... terial.zip
Code : Tout sélectionner
#CameraSpeed = 1
IncludeFile #PB_Compiler_Home + "examples/3d/Screen3DRequester.pb"
UsePNGImageDecoder()
Define.f KeyX, KeyY, MouseX, MouseY
If InitEngine3D(#PB_Engine3D_DebugLog)
Add3DArchive("./Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive("./Data/Models", #PB_3DArchive_FileSystem)
Parse3DScripts()
InitSprite()
InitKeyboard()
InitMouse()
If Screen3DRequester()
AmbientColor(RGB(255, 255, 255))
img_velo=LoadImage(#PB_Any,"./Data/Textures/velo.png")
;img_velo=LoadImage(#PB_Any,"velo.png")
texture_velo=CreateTexture(#PB_Any,ImageWidth(img_velo),ImageHeight(img_velo))
StartDrawing(TextureOutput(texture_velo))
DrawAlphaImage(ImageID(img_velo),0,0)
StopDrawing()
mesh_velo=LoadMesh(#PB_Any, "velo.mesh")
;mesh_velo=LoadMesh(#PB_Any, "./Data/Models/velo.mesh")
material_velo=CreateMaterial(#PB_Any, TextureID(texture_velo))
MaterialBlendingMode(material_velo, #PB_Material_AlphaBlend)
entity_velo=CreateEntity(#PB_Any, MeshID(mesh_velo), MaterialID(material_velo))
MoveEntity(entity_velo,10,0,0)
mesh_maison=LoadMesh(#PB_Any, "maison_1_obj.mesh")
entity_maison=CreateEntity(#PB_Any, MeshID(mesh_maison), #PB_Material_None )
CreateCamera(0, 0, 0, 100, 100) ; Front camera
MoveCamera(0, 0, 1, 20, #PB_Absolute)
CameraBackColor(0, RGB(55, 0, 0))
Repeat
Screen3DEvents()
If ExamineMouse()
MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
EndIf
If ExamineKeyboard()
If KeyboardPushed(#PB_Key_Left)
KeyX = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Right)
KeyX = #CameraSpeed
Else
KeyX = 0
EndIf
If KeyboardPushed(#PB_Key_Up)
KeyY = -#CameraSpeed
ElseIf KeyboardPushed(#PB_Key_Down)
KeyY = #CameraSpeed
Else
KeyY = 0
EndIf
EndIf
RotateEntity(entity_velo, 0, 0.3, 0, #PB_Relative)
RotateEntity(entity_maison, 0, 0.3, 0, #PB_Relative)
RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
MoveCamera (0, KeyX, 0, KeyY)
RenderWorld()
Screen3DStats()
FlipBuffers()
Until KeyboardPushed(#PB_Key_Escape) Or Quit = 1
EndIf
Else
MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf
End
Merci pour votre aide.22:25:14: Mesh: Loading maison_1_obj.mesh.
22:25:14: Texture: papier_mouche_1.jpg: Loading 1 faces(PF_R8G8B8,1944x1296x1) with 10 generated mipmaps from Image. Internal format is PF_X8R8G8B8,1944x1296x1.
22:25:15: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource papier_ondul__1.jpg in resource group General or any other group. in ResourceGroupManager::openResource at OgreResourceGroupManager.cpp (line 756)
22:25:15: Error loading texture papier_ondul__1.jpg. Texture layer will be blank. Loading the texture failed with the following exception: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource papier_ondul__1.jpg in resource group General or any other group. in ResourceGroupManager::openResource at OgreResourceGroupManager.cpp (line 756)
22:25:15: Texture: paperTextureNo4401_preview.jpg: Loading 1 faces(PF_R8G8B8,400x400x1) with 8 generated mipmaps from Image. Internal format is PF_X8R8G8B8,400x400x1.