Yue Posted June 14, 2018 Share Posted June 14, 2018 ventana = Window:Create() lienzo = Context:Create( ventana ) mundo = World:Create() local sol = DirectionalLight:Create() sol:SetRotation(90, 0, 0 ) local camara = Camera:Create() local suelo = Model:Box() suelo:SetScale(5, 0.2, 5 ) suelo:SetPosition( 0, -1, 5 ) suelo:SetPickMode(0) local punto = Model:Cone() punto:SetPosition ( 0, 0, 5 ) punto:SetColor ( 1, 0, 0 ) punto:SetPickMode(0) while true do if mundo:Pick(0, 10, 5,0, -10, 5, PickInfo(),1.0, true ) then return false end if ventana:Closed() then return false end Time:Update() mundo:Update() mundo:Render() lienzo:Sync() end Hi, I'm trying to understand lightning, but this doesn't work, from my perspective I create a lightning bolt from the red cone to the ground, and if it collides I expect the program to close. What am I doing wrong? Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted June 14, 2018 Share Posted June 14, 2018 Pickmode 0 ignores picking. https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_SetPickMode 1 Quote Link to comment Share on other sites More sharing options...
Yue Posted June 14, 2018 Author Share Posted June 14, 2018 Okay, I've already removed that command, but it still doesn't work. ventana = Window:Create() lienzo = Context:Create( ventana ) mundo = World:Create() local sol = DirectionalLight:Create() sol:SetRotation(90, 0, 0 ) local camara = Camera:Create() local suelo = Model:Box() suelo:SetScale(5, 0.2, 5 ) suelo:SetPosition( 0, -1, 5 ) local punto = Model:Cone() punto:SetPosition ( 0, 0, 5 ) punto:SetColor ( 1, 0, 0 ) local pis = PickInfo() while true do if ventana:Closed() then return false end Time:Update() mundo:Update() mundo:Render() lienzo:Sync() if mundo:Pick(0, 10, 5,0, -10, 5, pis,1.0, true ) then ventana:Closed() end end Any suggestions? Quote Link to comment Share on other sites More sharing options...
Yue Posted June 14, 2018 Author Share Posted June 14, 2018 suelo:SetPickMode( Entity:PolygonPick) <<< error on lua. info documentation. Quote Link to comment Share on other sites More sharing options...
Josh Posted June 14, 2018 Share Posted June 14, 2018 Try . Instead of : however it should work without explicitly setting the pick mode 1 Quote My job is to make tools you love, with the features you want, and performance you can't live without. Link to comment Share on other sites More sharing options...
Solution macklebee Posted June 14, 2018 Solution Share Posted June 14, 2018 The pick is working - you just are not confirming if the pick is occurring correctly. if mundo:Pick(0, 10, 5,0, -10, 5, pis,1.0, true ) then ventana:Closed() end ventana:Closed() does not close the window, it only checks if the window has been closed. Refer to the documentation: Window:Closed() I would suggest doing a 'System:Print()' as a way to confirm if the pick was successful. But if you really want to exit the program after the first loop when the pick is successful then change the code to this: if mundo:Pick(0, 10, 5,0, -10, 5, pis,1.0, true ) then System:Print("Pick Successful") return false end Edit -- also, unless the user knows exactly what they are doing and what to expect, I would advise you to stay away from giving your pick a radius as its slower and may give unwanted results. I'd advise you to use the precise raycast by using a radius of '0'. 2 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...
Yue Posted June 14, 2018 Author Share Posted June 14, 2018 Okay, this is working, the learning process is very cruel when you use the translator and start testing and making mistakes to come to some conclusion. So I'm getting the hang of this little by little. Is there a way to see the beam? Another question, do I just put numbers here? suelo:SetPickMode( 0) suelo:SetPickMode( 1) Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 14, 2018 Share Posted June 14, 2018 Have I mentioned how much I dislike the tech *** forum? Fixed the OP's issue, but who knows because if the OP likes the answer, it removes the post from the order of the discussion. ****ing Garbage. Anyways. your choices for SetPickMode() as found in the documentation: 0: pick tests will skip this entity. Entity::SpherePick: a sphere test with the entity pick radius will be used. Entity::PolygonPick: if the entity is a model or a brush, a precise polygonal pick test will be performed. Entity::BoxPick: a box test with the entity pick radius will be used I'd advise you to RTM. <<-- polite version. And no, you can't see the "beam". You can draw the "beam" if you wish using DrawLine or creating/scaling a polygon model from the start and end pick points. There are examples of this if you search the forum for "beam" 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...
Yue Posted June 14, 2018 Author Share Posted June 14, 2018 Ok, suelo:SetPickMode( suelo.PolygonPick, false ) ventana = Window:Create() lienzo = Context:Create( ventana ) mundo = World:Create() local sol = DirectionalLight:Create() sol:SetRotation(90, 0, 0 ) local camara = Camera:Create() local suelo = Model:Box() suelo:SetScale(5, 0.2, 5 ) suelo:SetPosition( 0, -1, 5 ) suelo:SetPickMode( suelo.PolygonPick, false ) local punto = Model:Cone() punto:SetPosition ( 0, 0, 5 ) punto:SetColor (1, 0, 0 ) local pis = PickInfo() while true do if ventana:Closed() then return false end Time:Update() mundo:Update() mundo:Render() lienzo:Sync() if mundo:Pick(0, 10, 5,0, -10, 5, pis,0, true ) then System:Print("Pick Successful") return false end Okay, this is working, now it's my turn to think about how to implement this so that a camera collides. Quote Link to comment Share on other sites More sharing options...
Yue Posted June 14, 2018 Author Share Posted June 14, 2018 1 hour ago, AggrorJorn said: Pickmode 0 ignora la selección. https://www.leadwerks.com/learn?page=API-Reference_Object_Entity_SetPickMode ventana = Window:Create() lienzo = Context:Create( ventana ) mundo = World:Create() local sol = DirectionalLight:Create() sol:SetRotation(90, 0, 0 ) local camara = Camera:Create() local suelo = Model:Box() suelo:SetScale(5, 0.2, 5 ) suelo:SetPosition( 0, -1, 5 ) suelo:SetPickMode( 0, true ) local punto = Model:Cone() punto:SetPosition ( 0, 0, 5 ) punto:SetColor (1, 0, 0 ) local pis = PickInfo() while true do if ventana:Closed() then return false end Time:Update() mundo:Update() mundo:Render() lienzo:Sync() if mundo:Pick(0, 10, 5,0, -10, 5, pis,0, true ) then System:Print("Pick Successful") return false end end Well, I'm telling you that even though it's at zero, the lightning still detects the ground from the cone. I'm confused. I'm confused. Quote Link to comment Share on other sites More sharing options...
macklebee Posted June 14, 2018 Share Posted June 14, 2018 8 minutes ago, Yue said: Well, I'm telling you that even though it's at zero, the lightning still detects the ground from the cone. I'm confused. I'm confused. You are doing a World Pick on the global Y-axis from +10 to -10. The pick is returning that it successfully picked something between these two points. The raycast is not from the cone. The raycast starts at the (0,10.5) point in space. The raycast ends at (0,-10,5), If it hits anything, it will return true. You have the cone sitting right where this raycast is occurring. It is hitting the cone. Try reading the documentation and try out the examples. World:Pick() 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...
Yue Posted June 14, 2018 Author Share Posted June 14, 2018 4 minutes ago, macklebee said: You are doing a World Pick on the global Y-axis from +10 to -10. The pick is returning that it successfully picked something between these two points. The raycast is not from the cone. The raycast starts at the (0,10.5) point in space. The raycast ends at (0,-10,5), If it hits anything, it will return true. You have the cone sitting right where this raycast is occurring. It is hitting the cone. Try reading the documentation and try out the examples. World:Pick() Ok, so as not to waste time, with this method I can set the collision for a third person camera, or do I have to think about something else? Quote Link to comment Share on other sites More sharing options...
Yue Posted June 14, 2018 Author Share Posted June 14, 2018 ventana = Window:Create() lienzo = Context:Create( ventana ) mundo = World:Create() local sol = DirectionalLight:Create() sol:SetRotation(90, 0, 0 ) local camara = Camera:Create() local suelo = Model:Box() suelo:SetScale(5, 0.2, 5 ) suelo:SetPosition( 0, -1, 5 ) --suelo:SetPickMode( 0, true ) local cono = Model:Cone() cono:SetPosition ( 0, 0, 5 ) cono:SetColor (1, 0, 0 ) cono:SetPickMode( 0, true ) local pis = PickInfo() while true do if ventana:Closed() then return false end Time:Update() mundo:Update() mundo:Render() lienzo:Sync() if mundo:Pick(cono:GetPosition(true).x, cono:GetPosition(true).y, cono:GetPosition(true).z , 0, -10, 5, pis,0, true ) then System:Print("Pick Successful") suelo:SetColor( 1, 1, 0 ) end end Okay, I'm getting this, the plan is that the beam will turn with the cone to another entity, that's what I think is a possible way to detect a camera collision. Quote Link to comment Share on other sites More sharing options...
Yue Posted June 14, 2018 Author Share Posted June 14, 2018 ventana = Window:Create() lienzo = Context:Create( ventana ) mundo = World:Create() local sol = DirectionalLight:Create() sol:SetRotation(90, 0, 0 ) local camara = Camera:Create() local suelo = Model:Box() suelo:SetScale(5, 0.2, 5 ) suelo:SetPosition( 0, -1, 5 ) --suelo:SetPickMode( 0, true ) local cono = Model:Cone() cono:SetPosition ( 0, 0, 5 ) cono:SetColor (1, 0, 0 ) cono:SetPickMode( 0, true ) camara:SetParent(cono,true) local pis = PickInfo() while true do cono:Turn(1, 0, 0 ) if ventana:Closed() then return false end Time:Update() mundo:Update() mundo:Render() lienzo:Sync() if mundo:Pick(cono:GetPosition(true).x, cono:GetPosition(true).y, cono:GetPosition(true).z , camara:GetPosition(true).x, camara:GetPosition(true).y, camara:GetPosition(true).z, pis,0, true ) then System:Print("Pick Successful") suelo:SetColor( 1, 1, 0 ) else suelo:SetColor( 1, 0, 0 ) end end :) 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.