9 Replies Latest reply on Dec 6, 2006 1:50 AM by Pyro-ct

    question! plz help

    Pyro-ct
      ok what i tried to do is this, i have a model of a galil rifle i made, and the model is devided into different elements, i want to be able to address each element seperatly in the code but i dont know how to, using the member.model method address the whole model, another thing i tried to to is to devide the model into seperate groups in the 3D program and export it as a W3D file, my plan was to clonemodelfromcastmember them all and put them in a list, i think it worked fine cuz the put(list) command actually details all the models in the scene, the problem is that i cant see anything in the shockwave window itself!
      this was kinda hard to explain so il just put the code here
      also heres the model and the director file, if anyone wanna get down and dirty
      plz help! thanks!

      http://www.planetnana.co.il/pyro-ct/galil.zip



      property my,m,mr
      property i,e


      on tran lis,u,v,w
      repeat with i = 1 to count(lis)
      lis .translate(u,v,w)
      end repeat
      end




      on beginsprite me
      my = sprite(me.spritenum)
      my.member.resetworld()

      mr = [] --model resource
      m = [:] --models list

      e=member("galil").model.count

      repeat with i = 1 to e
      mr.add (member("galil").modelresource
      )
      m.addprop (#"model "& i , my.member.newmodel("model " & i , mr ))
      end repeat

      put (mr)
      put (m)

      tran(m,0,0,0)
      end


        • 1. Re: question! plz help
          Pyro-ct Level 1
          plz ignore the trans function there, its not relevant now
          • 2. Re: question! plz help
            Level 7
            Do you have any lights in the W3D scene that is on stage? That would
            certainly explain why you are not seeing anything...
            • 3. Re: question! plz help
              Pyro-ct Level 1
              realy? but so far i never changed the default light and it allways worked
              dunno why it dosnt work now, i tried to add light but its still all dark
              • 4. Re: question! plz help
                Necromanthus Level 2
                just use the following piece of script:
                • 5. Re: question! plz help
                  duckets Level 1
                  quote:

                  Originally posted by: Pyro-ct
                  ok what i tried to do is this, i have a model of a galil rifle i made, and the model is devided into different elements, i want to be able to address each element seperatly in the code but i dont know how to, using the member.model method address the whole model



                  It's worth bearing in mind that some 3d modelling applications (3ds max in particular) will actually condense a group of objects down to a single object when exporting to w3d. Therefore a group of objects called 'rifle group', which contains 10 models, might be exported as a single model called 'rifle group'.

                  To preserve your model compents within the group, you'll need place each individual component into its own group, and then group them all together. Grouping each model individually (so that each model is a "group of one") before grouping them as a whole, will prevent the exporter from collapsing all into a single mesh

                  - Ben


                  • 6. Re: question! plz help
                    Pyro-ct Level 1
                    well i did, the w3d file is composed of several models that have different names
                    it all "seems" to work, the list is filled with models references and names just fine, the only problem is that whene i run the movie they dont show

                    is there a way to maybe address different elements of each model?
                    • 7. Re: question! plz help
                      Necromanthus Level 2
                      quote:

                      Originally posted by: Pyro-ct
                      well i did, the w3d file is composed of several models that have different names
                      it all "seems" to work, the list is filled with models references and names just fine, the only problem is that whene i run the movie they dont show


                      That's because your script doesn't clone anything.
                      Besides that, those 2 arrays are a waste of resources (RAM in this case). You don't need them at all.
                      You can access at runtime any model, any resource and any property without those (text) lists.
                      Anyway, if you need badly those arrays, here is the complete (and working !) script:

                      • 8. question! plz help
                        duckets Level 1
                        Having looked at your code more closely, your problem appears to be that you are trying to use a 'model resource' from one scene, as the resource for a new model in another. Resources can't shared across 3d cast members like this. To clone a model from one scene into another (which therefore also clones the model's resource), you need to use "cloneModelFromCastMember".

                        Here's how I would modify your code to make it functional (attached below).

                        Things to note:

                        I have called 'preload' on the source scene (the scene we are cloning from). Otherwise, because this 3d cast member does not appear on stage, it won't yet be loaded into ram, and will cause an error when attempting to clone.

                        When using cloneModelFromCastmember, you have to specify the source model by name, so I have added this code to your loop. You could also use this 'sourceModelName' as the name for each new model. This way, the models in your destination scene would have the same names as the models in the source scene, instead of 'model 1' 'model 2' etc.

                        A couple of small things:
                        You didn't need to declare 'i' and 'e' as properties, since you were only using them locally in scope. For example, you didn't need to remember the values for 'i' and 'e' when the handler finishes.

                        Your 'tran' function seems to simply translate a list of objects, which kind of replicates the purpose of 'group' nodes in the 3d scene, in a slower fashion. If you want to translate (or manipulate in any way) a group of models, simply create a group object (using lingo: newGroup) and set each model's "parent" property to that group. You can than translate the group and all objects will move along with it.

                        hope this helps!

                        - Ben

                        • 9. Re: question! plz help
                          Pyro-ct Level 1
                          oh now i see.. now that i think of it i dont know why i didnt use clonemodelfromcastmamber in the first place
                          maybe im just going into the deep water too soon
                          gotto learn more basic stuff first

                          thanks for the help!