4 Replies Latest reply on Jul 11, 2007 5:44 AM by danieloizo

    How to get a model from a group

    Jakob Wagner 2048 Level 1
      Hi

      I'm doing a 3D project in Director using Javascript.

      I have to 3D members. a "world" and a "content". I dynamically copy groups from the content to the world. The groups i copy contain models which make up chairs.

      I'm doing something like:

      member("world").cloneModelFromCastmember("chair1",chair, member("content"));
      member("world").cloneModelFromCastmember("chair2",chair, member("content"));

      Now I need to set the texture of the seat of each chair to a new texture. How do I access the "seat" model which is inside the chair1 group in the world member?

      Please answer even if you just have a hint.

      Jakob
        • 1. Re: How to get a model from a group
          Jakob Wagner 2048 Level 1
          Here is som more details. The 3d members are now called "world" and "testScene".

          My full script look like this:

          function startMovie()
          {
          initScene();
          }
          function initScene()
          {
          member("world").resetWorld();
          member("testScene").resetWorld();
          sprite(1).antiAliasingEnabled = true;
          member("world").cloneModelFromCastmember("chair1", "chair", member("testScene"));
          member("world").cloneModelFromCastmember("chair2", "chair", member("testScene"));
          var m1 = getModel("chair1", "world");
          var m2 = getModel("chair2", "world");
          m2.transform.position=vector(10,0,0);//moves the one group so both are visible

          // tries to get the seat model which is inside the chair1 group
          trace(m1.seat) // Returns: [function seat]
          //trace(m1.getProp("model", "seat")) // ERROR: Handler not defined
          //trace(m1.getProp("model", 1)) // ERROR: Handler not defined
          trace(m1.getPropRef("model", 1)) // Returns: <model("chair1")>

          }
          //
          // getModel
          //
          function getModel(modelName, memberName)
          {
          for (var i = 1; i <= member(memberName).count(symbol("model")); i++)
          {
          if ((member(memberName).getProp("model",i).name) == modelName)
          {
          return member(memberName).getProp("model",i);
          break;
          }
          }
          }

          Hope you can help.
          • 2. Re: How to get a model from a group
            danieloizo Level 1
            Hy,

            This is how you select (with lingo) a model from inside a group:

            member("world").group("chair1").model("seat")

            daniel.
            • 3. Re: How to get a model from a group
              tedalde2 Level 2
              cloneModelFromCastmember clones models, not groups. If the "chair1" model has a Director-child model named "seat", then it will clone. But if you created "seat" in your modeling software and grouped it there (3dsmax), then "seat" will become a sub-mesh of chair. If so, you can set the shaderlist[x] property of the chair model, where x is the submesh index of the seat submesh. You just have to figure out what x is.
              • 4. Re: How to get a model from a group
                danieloizo Level 1
                ... true, to figure x out, you can use 3DPI, it's a very useful tool!