5 Replies Latest reply on Jan 22, 2007 12:44 AM by otterman

    modelUnderLoc problems

    otterman
      Ok, Im using this simple script to determine the name of the model im clicking on- easy peasy!

      on mouseUp
      pt = the mouseLoc - point(sprite(5).left, sprite(5).top)
      m = sprite(5).camera.modelUnderLoc(pt)
      put m
      end

      The problem Im faced with is that the 3d object is fairly complex- using modelUnderLoc gets very sluggish as soon as I click on areas that have several overlapping models!

      There are only a few actual models i need to react to modelUnderLoc (hotspots). Is there anything I can do to better increase this performance?
        • 1. Re: modelUnderLoc problems
          tedalde2 Level 2
          Use modelsUnderLoc() instead of modelUnderLoc(), and use a parameter list. Check out the HELP on it. MUL tests take lots of time, but using a parameter list with few max models, #simple detail, and a modelList, you can maximize performance. Your parameter list would look something like this:

          modlist = [yourScene.model("mod1"), yourScene.model("mod2")... ]
          paramlist = [#maxNumberOfModels: 1, #levelOfDetail: #simple, #modelList: modlist]
          modelsPicked = sprite(5).camera.modelUnderLoc(pt, paramlist)

          You might want to make your modlist and paramslist a script property and set it up at beginsprite time. Also, beware that MUL will only test for the models in your list, and ignore all others. This means that anything in front of the listed models will not act as a barrier to clicking; but it sounds like this is what you want. But you can add "barrier" models by simply adding them to your modlist.
          • 2. Re: modelUnderLoc problems
            otterman Level 1
            Hey tedalde2, im gonna investigate this further. Been dragged off onto another project so this is on the backburner at the moment.

            Cheers for pointing me in the right direction anyways.
            Will keep you posted
            • 3. Re: modelUnderLoc problems
              otterman Level 1
              Hey, Ive had success and failer with this. Jumping up and down as performance is loads better thanks to tedalde2-credit due! The problem Im having now is that I cant successfuly extract the name of the model clicked on and use it for another command- Any suggestions?


              on mouseup

              TheModel = member("WLS scene")
              modlist = [TheModel.model("Hotspot1"),TheModel.model("Hotspot2"),TheModel.model("WLSlabels:Hotspot3 ")]
              paramlist = [#maxNumberOfModels: 1, #levelOfDetail: #simple, #modelList: modlist]

              pt = the mouseLoc - point(sprite(1).left, sprite(1).top)

              modelsPicked = sprite(1).camera.modelsUnderLoc(pt, paramlist)

              if modelspicked = [] then-----if not clicked on a model listed
              nothing
              else

              MyHotspot = modelspicked[1]

              member("WLS Scene"). MyHotspot .shader.blend = 100--------------THIS NOT WORKING ???????
              end if
              end
              • 4. Re: modelUnderLoc problems
                tedalde2 Level 2
                MyHotspot is a reference to the model. Just leave off the member("WLS Scene"), that's probably what's breaking it. You can access the clicked model name, MyHotspot.name, or access the shader properties, MyHotspot.shader.blend... It should work.
                • 5. Re: modelUnderLoc problems
                  otterman Level 1
                  Tedalde2 Bang on! Major milestone-now I can get on with some real work. Thanks for the guidence!