3 Replies Latest reply on Jun 1, 2006 3:16 AM by a¿ex

    Hiding/unhiding parts of model

    Wriker
      I am trying to hide & unhide part of a model, for example one side of a box, by setting model[aModel].resource.front to FALSE to hide it, and back to TRUE to unhide it. This works, except that it loses it shader when I set it to FALSE.

      Is there another way to temporarily hide parts of a model, without losing shader properties? Setting blend to 0 doesn't work, because then it hides ALL sides of the box (I guess because all sides use the same shader).
        • 1. Re: Hiding/unhiding parts of model
          James Newton, ACP Level 3
          How hard is it to create an object which...

          * uses a property to remember which shader was used on that mesh
          * hides the mesh
          Then
          * restores the mesh
          * restores the shader

          ...?
          • 2. Re: Hiding/unhiding parts of model
            Wriker Level 1
            Harder than you'd think. It restored not even half the shaders, for some reason.

            --hide
            pRememberShaders.addProp(aModel, gWorld.model[aModel].shaderList)

            --unhide
            gWorld.model[aModel].shaderList = pRememberShaders.getProp(aModel)

            If I output pRememberShaders to the message window, it does appear complete.
            • 3. Re: Hiding/unhiding parts of model
              a¿ex Level 1
              quote:

              Originally posted by: Wriker
              Harder than you'd think. It restored not even half the shaders, for some reason.

              --hide
              pRememberShaders.addProp(aModel, gWorld.model[aModel].shaderList)

              --unhide
              gWorld.model[aModel].shaderList = pRememberShaders.getProp(aModel)

              If I output pRememberShaders to the message window, it does appear complete.



              You stored a reference to the list.
              The variable points only to the list "shaderlist". If the list entries change the changes will be reflected in the variable too.

              You'll need the duplicate command to store the CURRENT state of the list:
              pRememberShaders.addProp(aModel, duplicate(gWorld.model[aModel].shaderList))

              this should work. nonetheless you must be careful. as the list contains pointers to the different shaders. if you delete one of these shaders, the list item will be void afterwards. So you can't rely on all being valid shader objects throughout the movie.

              If it was me, defensive programmer, I'd store the NAME of the shader I am interested in as a string and when I try to reste it later, I first check if a shader with the given NAME still exists in the 3-D member object.

              That's a matter of code design. There are different approaches.

              HTH