RE: PutUserData in custom operator
| Date : Wed, 1 Feb 2006 12:59:15 -0500 |
| To : <XSI(at)Softimage.COM> |
| From : "Mathieu Leclaire" <mleclair(at)hybride.com> |
| Subject : RE: PutUserData in custom operator |
|
Yes I saw those
but what I don’t understand is how to access them from inside the custom
operator. How do I verify if it exist and how do I extract the information? In the
example it creates it using: UserDataBlob myBlob ; root.AddProperty( L"UserDataBlob", false, L"udb", myBlob ) ; …then uses putvalue and
getvalue to pass information in and out so my guess is to use addproperty on
the object I’m applying the operator to but how do I extract the object… I know
using the ports I can have access to its kinematicstate or its primitive so
what then? Do I just use addproperty on the primitive or kinematicstate
directly or do I have to extract the parent (to get the object I’m adding my
operator to) and add the datablob to it directly? And how do I verify if it
already exist and extract the userdatablob object if it does? Or do I have to
create the datablob before applying the custom operator and pass the datablob
through the SPDL? This is where I’m still confused!! -----Original Message----- http://softimage.wiki.avid.com/sdkdocs/sicppsdk/html/classXSI_1_1UserDataBlob.html On 2/1/06, Mathieu Leclaire <mleclair(at)hybride.com
> wrote: Great, UserDataBlob is what I needed but
I'm still not sure I understand how to read and write them from inside a custom
operator though. You mentioned it would be better to do it in a custom command
and make them share the same DLL… not sure I understand how to do such a thing.
Do I have to link the UserDataBlob through the SPDL? A little example would be
appreciated. And btw, I just need to access it during
initialization but if you want to elaborate a little more about how you'd
manage the case where it would have to be updated every time the operator is
updated, I'd be great information to have in case I'm ever faced with such an
issue. Thanks for all the info! It really helps a
lot!! Mathieu -----Original
Message----- Subject: Re: PutUserData in custom operator Hi Mathieu, On 01/02/06, Mathieu Leclaire <mleclair(at)hybride.com>
wrote: OK… I've done more testing and seems the class and
pointers works fine… the problem was that I was trying to use PutUserData in a
syflex force using the syflex sdk… syflex data is saved using syXset( ctx,
(syXforce*)data ); that probably overrides my userdata and that's why I wasn't
getting the right results… now I have to figure out how to combine my userdata
to syflex's userdata… but I have a few ideas I'll try out… so that takes care
of my first problem but my second question still stands so if anyone has any
suggestions for that second issue, please share!! Thanks Mathieu Leclaire R&D Programmer Hybride -----Original Message----- Hi, I'm creating a custom operator and I need to initialize and
save data for each vertex of a polymesh. Since I have different kind of data to
save in the _init call of the operator and reload at each _update call, I
figured I'd create a class and put all my data in it then store that object
using the PutUserData() function of the UpdateContext. But since I allocate memory
in the constructor and delete that memory in the destructor, I think once I
pull back my data in the _update function using GetUserData(), it returns me
random data since it looks like the memory has already been released. Here is
an example of what I'm doing: #ifndef _myVertexInfo_h #define _myVertexInfo_h class myVertexInfo { private: int _nbPts; float* _targetPositions; int* _idxPts; public:
myVertexInfo (int nbPts) {
_nbPts = nbPts;
_targetPositions = new float[nbPts*3];
_idxPts = new int[nbPts*3]; } virtual ~myVertexInfo (){
delete [] _targetPositions;
delete [] _idxPts; } int GetNbPts() {
return _nbPts;
} … }; #endif Then in my operator's _Init function I do something like this: … //put local positions in obj2PtsPosArray. obj2PtsPosArray = inGeom.GetPoints().GetPositionArray(); int nb = obj2PtsPosArray.GetCount(); myVertexInfo * posData = new myVertexInfo (nb); … ctx.PutUserData( (CValue::siPtrType)posData ); Then pull it back in the _update function doing something like
this: CValue::siPtrType pUserData = ctx.GetUserData(); myVertexInfo * posData = (myVertexInfo *)pUserData; Application app; app.LogMessage(
CValue((float)posData->GetNbPts()).GetAsText());
But I lose all information saved from the _init call. So what am I
doing wrong? How do I allocate memory only in the _init function and release it
only in the _term function? I also have a second question: How can I store this information so
that when I load a model containing instances of that operator, it won't
recalculate all that information from the _init call but load the data
calculated when the operator was first applied. See, I only need to calculate
the necessary information when it's first applied, then use the calculated
information at every _update call of the operator. But if I export a model
containing instances of this operator, when I re-import it (usually by
switching the low resolution reference model by a higher resolution one that
contains this operator) then it recalls the _init of the operator and
recalculates all the values instead of reusing the values that where calculated
when first applied. I had the same problem with a previous operator I created
but I overcame the issue by adding a "FirstLoad" Boolean parameter to
the SPDL so that when it first got applied, it would change that parameter
value to false and save the desired data in the rest of the parameters and so
when it loaded again in a model, and the "FirstLoad" parameter value
was set to false, it would only read the parameters instead of recalculating
them. That worked well in that case because I only had a couple floats and a
couple integers that had to be saved per operator so I saved them as
parameters. Now I have whole arrays of data to save and it's length is
dependant on the number of vertices. How should I solve this issue? The only
solution I have in mind would be to save it to a file but then we'd have files
to manage with the model and paths to check… I'm looking for a way to save that
data directly into the operator or somewhere in the exported model so that I
can reload it when imported. Any suggestions? Thanks for any help you can provide and sorry for the lengthy post,
I just figure I'd better give too much information then not enough. Mathieu Leclaire R&D Programmer Hybride
|
- References:
- Re: PutUserData in custom operator
- From: Steven Caron <carons(at)gmail.com>
- Re: PutUserData in custom operator
| DATE: | << | >> | THREAD: | << | >> | INDEX: | Main | Thread |
|---|
- Previous by Date: RE: PutUserData in custom operator
- Next by Date: RE: PutUserData in custom operator
- Previous by Thread: RE: PutUserData in custom operator
- Next by Thread: RE: PutUserData in custom operator
- Index(es):
| Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available. |