It is currently Sun Mar 07, 2021 9:50 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: MousePick() on Plane is unusable...
PostPosted: Wed Jan 13, 2021 9:54 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 842
A MousePick() on a plane seems to be tested against a bounding box which is just stupid.
Is there a solution?

Example:
Code:

EnableExplicit

Procedure.i Main(Width.i = 960,Height.i = 600)
  Protected flags.i
  If InitEngine3D() And InitSprite()
    flags|#PB_Window_SystemMenu|#PB_Window_ScreenCentered
    flags|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget
    If OpenWindow(0,0,0,Width,Height,#Null$,flags)
      WindowBounds(0,Width,Height,#PB_Ignore,#PB_Ignore)
      If OpenWindowedScreen(WindowID(0),0,0,Width,Height,#True,0,0)
        SetFrameRate(60)
        ;------------------------------------------------------ setup scene
        AmbientColor(RGB(0,0,20))
        CreateLight(#PB_Any,RGB(160,160,180),0,100,0,#PB_Light_Point)
        CreateLight(#PB_Any,RGB(160,120,100),-100,100,-50,#PB_Light_Point)
        CreateCamera(0,0,0,100,100)
        MoveCamera(0,0,2,-4,#PB_Absolute|#PB_Local)
        CameraLookAt(0,0,0,0)
        CreatePlane(0,1,1,1,1,0,0)
        CreateEntity(0,MeshID(0),#PB_Material_None,0,0,0,1 << 1)
        CreateSphere(1,0.05)
        CreateEntity(1,MeshID(1),#PB_Material_None,0,0,0,1 << 2)
        ;------------------------------------------------------
        Repeat
          Repeat
            Select WindowEvent()
              Case #PB_Event_CloseWindow
                Break 2
              Case #Null
                Break
            EndSelect
          ForEver
          ;------------------------------------------------------ mouse pick -.-
          ResizeCamera(0,0,0,100,100)
          If MousePick(0,WindowMouseX(0),WindowMouseY(0),1 << 1) >= 0
            MoveEntity(1,PickX(),PickY(),PickZ(),#PB_Absolute)
          EndIf
          ;------------------------------------------------------
          RenderWorld()
          FlipBuffers()
        ForEver
      EndIf
      CloseWindow(0)
    EndIf
  EndIf
  ProcedureReturn
EndProcedure

Main()

End



Top
 Profile  
Reply with quote  
 Post subject: Re: MousePick() on Plane is unusable...
PostPosted: Thu Jan 14, 2021 9:41 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 895
Location: Denmark
Simple solution if you want the y-position to stay fixed in your example.
Code:
MoveEntity(1,PickX(),0,PickZ(),#PB_Absolute)

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: MousePick() on Plane is unusable...
PostPosted: Thu Jan 14, 2021 11:30 am 
Offline
Addict
Addict
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 842
Thx, but that is just a visual fix.
Ogre is selecting the wrong and slower intersection test... pretty dissapointing to say the least.
The only way i see to fix this mess is by also checking the normal of the intersection point.


Top
 Profile  
Reply with quote  
 Post subject: Re: MousePick() on Plane is unusable...
PostPosted: Thu Jan 14, 2021 12:27 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 10:06 am
Posts: 895
Location: Denmark
then use MouseRayCast() instead.

_________________
“Tell me and I forget. Teach me and I remember. Involve me and I learn.”
— Benjamin Franklin
Current configurations: Windows 10, Intel 6800K, GeForce Gtx 1060, 32 gb ram.


Top
 Profile  
Reply with quote  
 Post subject: Re: MousePick() on Plane is unusable...
PostPosted: Thu Jan 14, 2021 5:54 pm 
Offline
Addict
Addict
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 842
DK_PETER wrote:
then use MouseRayCast() instead.

That works thx :)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye