Whats my model number?

Otterman

Angry Mac User
OK, ive posted this on the director forum and its yielded nada, zip, naff all! Gona share this pickle with me fellow lightwavers, here gos nothing-

How do you get hold of the model number ive clicked on- heres the code ive worked on so far- just got the last part to figure out. Got a feeling this one is obvious and staring me in the face.



------ calculate the click location
upperLeft = point(sprite(1).left, sprite(1).top)
clickLocation = the mouseLoc - upperLeft

------ get the model there
if sprite(1).camera.modelUnderLoc(clickLocation) = false then
nothing
else
model = sprite(1).camera.modelUnderLoc(clickLocation)

------ send to message window (THE MODEL NUMBER)
put model() ?????
 

Otterman

Angry Mac User
Ok no magical lingo command but am just loopn through the models and see which index number is the one with the name of the clicked model.

script-

------ calculate the click location
upperLeft = point(sprite(1).left, sprite(1).top)
clickLocation = the mouseLoc - upperLeft

------ get the model there
if sprite(1).camera.modelUnderLoc(clickLocation) = false then
nothing
else
model = sprite(1).camera.modelUnderLoc(clickLocation)

repeat with n = 1 to sprite(1).member.model.count
if sprite(1).member.model[n].name = model.name then
------ send to message window (THE MODEL NUMBER)
put n
end if
end repeat
end if
 

Sam_Horton

New member
find a model's number

It's seems weird that director allows you to look up the model's name, but not it's number

Here's a script that runs pretty fast!

Code:
property w3d, cam, mList

on beginSprite me  
  --variables are good!
  w3d = sprite(1).member
  cam = w3d.camera(1)
  
  --build a list of all the models in the scene
  mList = []
  repeat with i = 1 to w3d.model.count
    m = w3d.model(i)
    mList.add(m.name)
  end repeat
end

on exitFrame me
  m = cam.modelUnderLoc(the mouseLoc)
  if m <> void then
    --find the position in mlist of model m's name
    put mList.findpos(m.name)
  end if
  go the frame
end
 
Last edited:
Top Bottom