Re: SCOPs with more than one output...

Date : Sun, 30 Dec 2007 22:02:31 +0000
To : XSI(at)Softimage.COM
From : "Dan Yargici" <danyargici(at)gmail.com>
Subject : Re: SCOPs with more than one output...
Hi Brad,

I'm new to writing psuedo code (as you'll quickly notice...) and I don't have the actual code in front of me, so excuse the mess!  Obviously there's more to it, but basically it goes like this....


Check for cluster called "VelocityMap" - If not found, then create complete point cluster "VelocityMap" and make a UserDataBlob under it called "PointCache" and weightmap called "VelocityWeightmap"

Get point position array for current frame:
PosArray = oObj.ActivePrimitive.Geometry.Points.PositionArray.toArray()

Create two new arrays - DumpArray and ConcatArray

Add position array to DumpArray twice using the concat method (the cache will always contain the last two frames' positions, doing this just ensures that the scop finds the right amount of data).

DumpArray = ConcatArray.concat(PosArray, PosArray)  (can't remember why I needed two arrays...)

Dump new array onto the UserDataBlob.

PointCache = DumpArray

Create scop on VelocityWeightmap (Inputs: PointCache, Geometry, VelocityWeightmap - Outputs: PointCache, VelocityWeightmap - Variable: Threshold)

SCOP:

BEGIN

Take the cached data from the UserDataBlob as a string, use the split command (delimitier ",") to create a new, clean array.  This, because I found that even though I give the UserDataBlob an array it returns one with a much greater length, almost as if it treats any non-alphanumeric characters as a delimiter (Perhaps a side effect of using concat???)

Split this array in two using slice method returning: ArrayA and ArrayB

Get current frame's point positions returning: ArrayC

if Out.name = WeightMap
{
    var NewWeightsArray = new Array()
    For each i in pointcollection :
    {
        aX = ArrayA[i*3]
        ay = ArrayA[i*3+1]
        az = ArrayA[i*3+2]

        bX = ArrayB[i*3]
        by = ArrayB[i*3+1]
        bz = ArrayB[i*3+2]

        cX = ArrayC[i*3]
        cy = ArrayC[i*3+1]
        cz = ArrayC[i*3+2]

        posV1 = aX, aY, aZ
        posV2 = bX, bY, bZ
        posV3 = cX, cY, cZ

        velV1 = posV2 - posV1
        velV2 = posV3 - posV2

        accV1 = velV2 - velV1

        accVecLen = Math.abs(accV1.length)

        Compare accVecLen against Threshold
        If greater or equal
        {
            NewWeightsArray[i] = 1
        }
        else
        {
            NewWeightsArray [i] = 0
        }
        Out.value = NewWeightsArray
    }
}

if Out.name = Cache
{
    var tempArray = new Array()
    var OutCache = new Array()
   
    Out.value = tempArray.concat(ArrayB, ArrayC)  (again, can't remember why I needed two arrays...)
}

END

This makes is look faaaar messier than it actually is!

DAN


On Dec 29, 2007 6:55 PM, Bradley Gabe <withanar(at)gmail.com> wrote:
Dan-
 
I'm not as advanced in working with SCOPs as some others (Guy and Kim come to mind). And while I have used UserDataBlobs many times, I have always used them as a container for a static data set from which the SCOP accesses the information. I have attempted using SCOPs to store data sets within their UserData, however I've found there are smaller memory limits. So if your meshes are not too big, you can try that route.
 
Perhaps you can list out your steps as psuedo code? That's not a total giveaway but it might help in figuring out why XSI is not setting your SCOP as dirty. In the meantime, I'm going to try a simple experiment which is a SCOP that writes current frame info to a UserDataBlob, and then reads what was stored there on frame update. If I can get that to work, then I'll post the code, which you can then hopefully convert into your data read/write situation.
 



Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.