RE: [CPP] Storing data in a compileOp

Date : Mon, 12 Dec 2005 15:30:33 +0100
To : XSI(at)Softimage.COM
From : Fernando Navarro <f.navarro(at)bren.es>
Subject : RE: [CPP] Storing data in a compileOp

 

            Hi All:

            In order to use Init/Update/Term in that way (and ensure your data is fully persistent) you’ll have to switch on plugin cache (File > Plugins > Manager… Custom operator active).

            If you switch off cache, your operator will be inited + updated + terminated on every operator update, losing your saved data.

 

            A workaround for that is using user data blobs. Even using one blob per object is not necessary: put data from all your objects under a blob owned by a known object/model.

 

            If you think about persistence through scene loading/saving, you will have to use data blobs (or keyframe initial position and play your animation from the beginning)

 

            That helped me!

                        Fernando Navarro

 

 

 

-----Mensaje original-----
De: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] En nombre de Guy Rabiller
Enviado el: lunes, 12 de diciembre de 2005 14:43
Para: XSI(at)Softimage.COM
Asunto: Re: [CPP] Storing data in a compileOp

 



> ../.. The data should persist until I
> delete the compiledOperator. ../..

This should be automatic, as long as you use a class for your compiled operator rather than directly using the callbacks.

First create a Class wich has the 3 members Init/Update/Term with similar arguments as of the callbacks.
Then when in the operator Init callback, create a new instance of your class then

CYourClass* pYourInstancePointer = new CYourClass();
inCtx.PutUserData( (CValue::siPtrType)pYourInstancePointer );
pYourInstancePointer->Init(inCtx);


In the Update and Term, retrieve your pointer:

CValue::siPtrType pUserData = in_ctx.GetUserData();
CYourClass* pYourInstancePointer = (CYourClass*)pUserData;

and either
pYourInstancePointer->Term(inCtx)
or
pYourInstancePointer->Update(inCtx, outPort)

Now your Class can contain any public or private members/properties, and it will be persistent until you delete the operator.

> ../..I'm making a customOperator that will be working ../..

I meant why would you want to call the function from outside of your Class/Operator ?

--
guy rabiller | 3d technical director (at) LaMaison

Alan Jones a écrit :

Hi Guy,

The data should persist until I delete the compiledOperator.

I'm making a customOperator that will be working as a constraint and I want to store the initial position of the point being constrained relative to another point (using pointLocatorData and a vector in tangent space) so I want to store both of those pieces during the init function. Then later I was to grab those - check the changed position of the point it's relative to and figure out the new location.

Cheers,

Alan.

On 12/12/05, Guy Rabiller <guy(at)alamaison.fr> wrote:


> ../.. I'd like to store some data (a vector)
> in my compiled op for it to reference later ../..

Define 'later' ?

How 'far' the data(s) should be persistent ?

> ../.. is there a way to call my own functions on the class ../..

Why would you do that ?
--
guy rabiller | 3d technical director (at) LaMaison


Alan Jones a écrit :

> Hi All,
>
> I'd like to store some data (a vector) in my compiled op for it to
> reference later - though I don't want the user to see it.
>
> I've looked at the init function - which seems like a good enough
> place to start, but can't seem to find a nice place to keep it. Is
> adding my own variables to the class going to break anything? or is
> that how I should be doing it?
>
> It might be nice to be able to change it from a command too - is there
> a way to call my own functions on the class if I add them or is
> update, init and term or I can really work within.
>
> Thanks for any help.
>
> Cheers,
>
> Alan.



---
Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
unsubscribe xsi

 

 

--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi

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.