LoadAnimMesh,EntityPickMode and TerraEd
Blitz3D Forums/Blitz3D Programming/LoadAnimMesh,EntityPickMode and TerraEd
| ||
Hi! When using EntityPickMode=2, CameraPick and LinePick may not return the same handle that was returned by LoadAnimMesh. Instead, you may get the handle of a child of the object, and a direct comparison (of the value returned by LoadAnimMesh, to the value returned by CameraPick) will fail. This is not an issue with LoadMesh, since parent/child info does not get loaded by that method. This issue (with EntityPickMode=2) comes up in TerraEd, because TerraEd calls LoadAnimMesh for everything. Here is a solution to the problem. ;Typical use of CameraPick to select an object MyPickEntity = CameraPick(Cam, GraphicsWidth()/2, GraphicsHeight()/2) If MyPickEntity <> 0 Then For G.Game_Object=Each Game_Object If PickTest(G\Entity, MyPickEntity) Then ; Do Something Endif Next Endif ;Function that makes it work Function PickTest(TestEntity%, PickEntity%) If TestEntity = PickEntity Return True Children%=CountChildren(TestEntity) For n = 1 To Children% Test%=GetChild(TestEntity,n) EndSearch = PickTest(Test,PickEntity) If EndSearch Return True Next Return False End Function Feel free to use the above code as needed. Important: TerraEd has a function to get an object's Entity Handle: Ter_FindTerraObject(Name$). However, to use that function, A) the object must have "Culling" Reset, and (B) you must _first_ call Ter_UpdateTerra(Cam) - once for all objects - which sets the Entity Handles for all non-culled objects in the TerraEd map. Regards, Martonic |
| ||
An other solution is when you create a type or array for children. Right after loading you can store all child handles in such an array and in the second row of the array you would store the handle of the parent. So you only need to parse an array, this might be faster. Especially when recursive hierarchy isused in a model. |
| ||
Thanks for this addition :) |