Lunarovich Posted March 20, 2015 Share Posted March 20, 2015 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 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? Quote Link to comment Share on other sites More sharing options...
macklebee Posted March 20, 2015 Share Posted March 20, 2015 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 1 Quote 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 More sharing options...
Lunarovich Posted March 20, 2015 Author Share Posted March 20, 2015 Thanks. I did as you suggested. Here are the screenshots: I am printing values with local pos = pickinfo.position System:Print(pos.x .. " " .. pos.y .. " " .. pos.z) directly under the camera pick test. Quote Link to comment Share on other sites More sharing options...
macklebee Posted March 20, 2015 Share Posted March 20, 2015 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######'. Quote 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 More sharing options...
Lunarovich Posted March 20, 2015 Author Share Posted March 20, 2015 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! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.