Tomas Posted February 10, 2017 Share Posted February 10, 2017 ..... if self.camera:Pick(mousepos.x,mousepos.y,pickinfo) then self.picked_entity=pickinfo.entity if window:KeyDown(Key.L) then pickinfo.entity:Turn(0,Time:GetSpeed()*0.5,0) end end ...... Hi is it possible in any ways to inerract with terrain vegetation, like trees? I want trees to be cuttable, is there any way to do this? I tried picking, it picks the tree but any interaction like moving, hiding, rotating wont work Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 10, 2017 Share Posted February 10, 2017 Haven't tested it, but I assume you send a raycast from your player or camera. Although I don't know if you get the actual entity with the vegatation system. Quote Link to comment Share on other sites More sharing options...
Tomas Posted February 10, 2017 Author Share Posted February 10, 2017 I used a variable for picking and when a cursor was on the tree it was positive, also the tree material picking flag is set. I assume that picking is possible, but is it possible to ineract like change rotation? ... if self.camera:Pick(mousepos.x,mousepos.y,pickinfo) then self.picked_entity=pickinfo.entity if window:KeyDown(Key.L) then self.ok_picked=1 --pickinfo.entity:Hide() pickinfo.entity:Turn(0,Time:GetSpeed()*0.5,0) else self.ok_picked=0 end end ... self.ok_picked ws positive when cursor was on the tree Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 10, 2017 Share Posted February 10, 2017 What is the content of the pickinfo,entity when you pick a tree? If it is a normal entity, you can use all the normal entity API functions. Quote Link to comment Share on other sites More sharing options...
Tomas Posted February 10, 2017 Author Share Posted February 10, 2017 How can i check this? I mean content.. Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 10, 2017 Share Posted February 10, 2017 Well you could print its content to the output screen. You could retrieve its position, see if that is correct: pickinfo.entity:GetPosition() You can also enter debug mode (f5) and see what the content is. Ofcourse you need to set a breakpoint Quote Link to comment Share on other sites More sharing options...
Tomas Posted February 10, 2017 Author Share Posted February 10, 2017 pickinfo.entity:GetPosition() does not report any values (all 0) Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 10, 2017 Share Posted February 10, 2017 It might be possible that since you are using the vegetation system, the trees are not common entities. Placing trees by hand via the asset tree, will probably resolve that issue but has the down side of custom tree management. Quote Link to comment Share on other sites More sharing options...
Tomas Posted February 10, 2017 Author Share Posted February 10, 2017 but it has to be some entity this reports true: if self.picked_entity then context:DrawText("Picked".."entity",10,60) else context:DrawText("Picked ".."nothing",10,60) end Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 10, 2017 Share Posted February 10, 2017 And what does: pickinfo.entity:SetColor(1,0,0)? Does it paint the tree red? Quote Link to comment Share on other sites More sharing options...
Tomas Posted February 10, 2017 Author Share Posted February 10, 2017 no it doesnt. Have to hurry to work, talk to u later... Quote Link to comment Share on other sites More sharing options...
Genebris Posted February 10, 2017 Share Posted February 10, 2017 Try GetClass to understand what picking returns, it will probably be terrain class. http://www.leadwerks.com/werkspace/page/documentation/_/object/objectgetclass-r19 Quote Link to comment Share on other sites More sharing options...
AggrorJorn Posted February 10, 2017 Share Posted February 10, 2017 See Ricks answer in this post. Somewhere in the bottom he also mentions this. http://www.leadwerks.com/werkspace/topic/13941-scenes-and-stuff/page__hl__chop%20tree#entry96038 Quote Link to comment Share on other sites More sharing options...
Tomas Posted February 10, 2017 Author Share Posted February 10, 2017 ID=30 for terrain vegetation tree. Which is not docummented. Some "x" class. Terrain is 20 and model is 2. Quote Link to comment Share on other sites More sharing options...
Tomas Posted February 10, 2017 Author Share Posted February 10, 2017 I think any manipulation is not possible, since vegetation is not stored in memory but uses drawing algorithm which draws entities dynamically every frame depending on seed.... 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.