Jump to content

Camera:Pick very strange position.z results


Lunarovich
 Share

Recommended Posts

I'm implementing a camera picking with this code

 

if (window:MouseHit(1)) then
local pickinfo = PickInfo()
if (self.camera:Pick(context:GetWidth() / 2, context:GetHeight() / 2, pickinfo, 0, true)) then	
System:Print(pickinfo.position.z)
end
end

 

and I'm getting really wierd results concerning the pickinfo.position.z (x and y are correct). Here they are

 

a9F4Zaa.png

 

This happens only when I'm picking the cube (CSG, but happens with models as well) from the frontside, that is, when I'm facing in the positive z axis direction. When I slowly move the mouse and do the picking, I get different results (already impossible, since the cube side is aligned with the x axis) with impossible values...

 

EDIT: It seems that it happens only when the side of the cube is aligned with the x = 0. Could it be a bug?

Link to comment
Share on other sites

I am confused by your description. If the cube face that you are picking is aligned with the x-axis, then z = 0 (which relates to the values you are showing). It might help if you gave the position and size of the csg cube itself so we understand exactly where it is in global space.

 

Also, as a sanity check, place a non-pickable item at the position of the pick to visually see if the position is correct.

if (window:MouseHit(1)) then
  local pickinfo = PickInfo()
  if (self.camera:Pick(context:GetWidth() / 2, context:GetHeight() / 2, pickinfo, 0, true)) then
     System:Print(pickinfo.position.z)
     local sphere = Model:Sphere()
     sphere:SetPickMode(0)
     sphere:SetScale(.2,.2,.2)
     sphere:SetColor(1,0,0,1)
     sphere:SetPosition(pickinfo.position)
  end
end

  • Upvote 1

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Ok so the face's z-position is zero which is what the 'pos.z' is returning. Are you confused by the '#.#########e-007' numbers? That is just rounding discrepanacies, but essentially the 'e-007' (scientific notation) is telling you that the decimal is actually 7 places to the left which would make the value '0.000000######'.

Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590

LE / 3DWS / BMX / Hexagon

macklebee's channel

Link to comment
Share on other sites

Thanks. I knew it was the sci notation, but was puzzled by the fact that other sides that where axis aligned gave int results. What confused me here were leading zeros after the - sign, so I did not know if the number is very small or very large :) . Thought that we use only signifcant digits. Anyway, thanks again!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...