Graphics

 View Only
  • 1.  making copies

    Posted 03-21-2014 08:20
    I'm trying to duplicate group of objects in my scene and distribute them randomly around the screen. The number of copies is pulled from a database.

    is something like this possible?

    to start I am trying to create object using this code:

    OnOnline:

    dim quad as xpBaseObject

    dim j as Integer

    for j = 1 to 12

    Self.CreateObject("Quad", quad)

    quad.Name = "q"

    quad.PosX = 10*j

    next


    I get no errors - but I also don't see 12 quads? Any suggestions would be appreciated!

    thanks!


  • 2.  RE: making copies

    Posted 03-21-2014 12:15
    If you don't assign a material to the quads they will just be invisible/transparent.

    Use .SetMaterial to assign a material after retrieving it with engine.GetMaterialByName.

    #XPression


  • 3.  RE: making copies

    Posted 03-24-2014 08:48
    Thanks Brian!

    Another question: I have an xml file with unknown number of elements

    1. is there a way to find the total number of elements using scripts?

    2. is there a way to step thru the elements using script (ex: can I script dataliq keys values?)

    thanks again!

    #XPression


  • 4.  RE: making copies

    Posted 03-26-2014 12:30
    Ronen, you can not query the number of elements. If you exceed the number of elements there is an option to have the indexes wrap. E.g. If you query the 6th element of a datalinq with only 5 elements you'll get the first again.

    In recent versions (5.4 and above) You can script datalinq keys to step through a datalinq. One approach would be to put a script event on the scene director that increments the value of the datalinq key and does a RefreshDatalinqs. You could then have a loop event on the scene director to keep looping and advancing the value.

    Something like this:

    dim keys as xpDatalinqKeys

    dim key as xpDatalinqKey

    if Scene.GetDatalinqKeys(keys) then

    if keys.GetKeyByName("jersey", key) then

    key.AsString = (CInt(key.AsString)+1).ToString

    Scene.RefreshDatalinq

    end if

    end if

    #XPression


  • 5.  RE: making copies

    Posted 03-26-2014 20:30
    Thanks Brian, that seems like the way to do it, much appreciated!

    #XPression