how can I do this?

Blitz3D Forums/Blitz3D Programming/how can I do this?

Vorderman(Posted 2004) [#1]
If I have a data structure...

type TYPE_ob
  field mesh
  field x#,y#
end type


...and mesh is pickable, I can use camerapick to return the entity...

ENT = camerapick(cam,mousex,mousey)


...is there any way to go from the returned entity ENT to the associated data structure?

for example, to allow me then to set ENT\x# or whatever?


John Pickford(Posted 2004) [#2]

function which_type_ob_did_i_pick.type_ob (ENT)

  picked.type_ob=null

    for this.type_ob = each type_ob

      if this\mesh=ent then picked=this
    
    next

  return picked

end function




Binary_Moon(Posted 2004) [#3]
type TYPE_ob
  field mesh
  field x#,y#
end type

t.TYPE_ob = new TYPE_ob
t\mesh = createcube()

;-----

nameentity t\mesh,handle(t)

ENT = camerapick(cam,mousex,mousey)
t.TYPE_ob = object.TYPE_ob(entityname(ENT))


Ta Daaa


John Pickford(Posted 2004) [#4]
Ooh good one. I hadn't come across nameentity before.


Neochrome(Posted 2004) [#5]
store the pointer in the datastruct. faster than entityname


Vorderman(Posted 2004) [#6]
Cheers - I just discovered almost the same method that Binary_Moon posted, but yours is a bit slicker.

Thanks guys.
James