I don't know if you are aware of this forum, but just in case I post this new 'bug' or issue for your knowledge.
Please look at this tip.
I use a parent mesh for the camera, and I turn it using RMB , so the camera orbitates around it and everytime pointing to it.
The problem is the picking feature; as you can see, after you orbitate the camera around, the picking feature is not accurate, because the camera believes it is always pointing to frontal global coords due it is attached to its parent mesh (pivotcam).
Code: Select all
WindowWidth=640:WindowHeigh=480
MP_Graphics3D(WindowWidth,WindowHeigh,0,2)
ViewPortX=30:ViewPortY=60:ViewPortWidth=600:ViewPortHeigh=400
light=MP_CreateLight(1)
MP_CreateCube()
cam=MP_CreateCamera():pivotcam=MP_CreateMesh():MP_EntitySetParent(cam,pivotcam,0):MP_EntitySetZ(cam,-2); <--------- create a camera and attach it to a pivot entity
ViewPort=MP_CameraViewPort(cam,ViewPortX,ViewPortY,ViewPortWidth,ViewPortHeigh,$008B340A)
MP_CameraSetPerspective(cam,45,ViewPortWidth/ViewPortHeigh)
While WindowEvent()<>#PB_Event_CloseWindow
mdx.f=MP_MouseDeltaX()/200:mdy.f=MP_MouseDeltaY()/200
If MP_MouseButtonDown(1)
MP_TurnEntity(pivotcam,mdy*60,mdx*60,0,0); <------------------ I turn the pivot so the camera orbitates around it
EndIf
picked=MP_PickCamera(cam,WindowMouseX(0),WindowMouseY(0)):If picked:MP_Wireframe(1):Else:MP_Wireframe(0):EndIf
MP_DrawText(300,60,Hex(picked)+" found. Distance: "+StrF(MP_PickedGetDistance(),4))
MP_RenderWorld()
MP_Flip()
Wend