RE: Accessing UserDataBlob from Mental Ray

Date : Wed, 14 Jun 2006 10:38:07 -0400
To : <XSI(at)Softimage.COM>
From : "Mathieu Leclaire" <mleclair(at)hybride.com>
Subject : RE: Accessing UserDataBlob from Mental Ray
Title: Re: Accessing UserDataBlob from Mental Ray
that's right... it returns a pointer. My mind was elsewhere when I responded. Thanks for correcting me. Sorry Philipp. I'll try to be more focused next time I respond.
 
Mathieu
-----Original Message-----
From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM]On Behalf Of Halfdan Ingvarsson
Sent: Wednesday, June 14, 2006 9:04 AM
To: XSI(at)Softimage.COM; XSI(at)Softimage.COM
Subject: RE: Accessing UserDataBlob from Mental Ray

Eh.
 
miQ_DATA_PARAM gives back a *pointer*. It does not copy anything. The other thing is, if you initialise a UserDataBlob with a string, the string is a UNICODE string, not ASCII. So each character is two bytes. To wit:
 
wchar_t* wcsDataString;
mi_query(miQ_DATA_PARAM, NULL, tTheData, &wcsDataString);
mi_info( "*****Data String: %ls", wcsDataString);
 
Note red bits. This should work on both Windows and Linux.
 
 - ½


From: owner-xsi(at)Softimage.COM on behalf of Philipp Oeser
Sent: Wed 14-Jun-06 06:11
To: XSI(at)Softimage.COM
Subject: Re: Accessing UserDataBlob from Mental Ray

Eh...where was my "C for dummies"-book again?  :-[
Thanks Mathieu, trying out right now...

Greetings
Philipp


Mathieu Leclaire schrieb:
> try:
>
> miInteger iDataSize;
> mi_query(miQ_DATA_PARAM_SIZE, NULL, tTheData, &iDataSize);
> mi_info( "*****Data Size: %d", iDataSize);
>
> char* sDataString = new char[iDataSize];
> mi_query(miQ_DATA_PARAM, NULL, tTheData, sDataString);
> mi_info( "*****Data String: %s", sDataString);
>
>
> ...and don't forget to release the memory once you don't need sDataString
> anymore calling:
>
> delete [] sDataString;
>
>
> ...I beleive that should work... try it out and let me know.
> To explain: allocate memory with new... since it's a pointer, mi_query
> without the & and release the memory at the end.
>
>
> Mathieu Leclaire
> R&D Programmer
> Hybride Technologies
>
>
> -----Original Message-----
> From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM]On Behalf
> Of Philipp Oeser
> Sent: Tuesday, June 13, 2006 8:13 AM
> To: xsi(at)Softimage.COM
> Subject: Accessing UserDataBlob from Mental Ray
>
>
> Hi,
> second try at getting particle positions over to MentalRay (first was to
> read theParticleUserData directly but still cant do it).
> So this time: with own UserData. But I am having problems with
> retrieving the UserData from within a shader in MR. All I get is the
> first character of a string...
> so if I put "example" in a blob-string, in MentalRay I only get "e".
> I hope this is just some newbie C-thing or something, so if you can help
> me out, I'd be really happy :)
>
> So, in XSI i ad d the blob to my selection (in this case just a grid)
> and save a string with:
> (this is just scripting, not C++, so as I understood I can only save
> strings with it...)
> ............................................................................
> ...................
>
> set oSel = Selection(0)
> set oBlob = oSel.AddProperty( "UserDataBlob", , "data" )
> oBlob.Value = "example"
> SetValue oBlob&".RenderData", True
> SetValue oBlob&".UserDataID", 1111111
> .............................................................................
> ...................
>
>
> And, in MentalRay :
> ............................................................................
> ...................
>
> char *sTheData = "grid/data";
> miTag tTheData = mi_api_name_lookup(sTheData);
>
> miInteger iDataSize;
> mi_query(miQ_DATA_PARAM_SIZE, NULL, tTheData, &iDataSize);
> mi_info( "*****Data Size: %d", iDataSize);
>
> char* sDataString;
> mi_query(miQ_DATA_PARAM, NULL, tTheData, &sDataString);
> mi_info( "*****Data String: %s", sDataString);
> ............................................................................
> ...................
>
> The Data Size comes over nicely but the String ist truncated to the
> first character. So, as I said I'm pretty unstable in C and dont have a
> good understanding of what a blob is, so if you can point me in the
> right direction or tell me where i make mistakes, you'll save my day :)
>
> Greetz
> Philipp
> ---
> 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
>
>  

---
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.