Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk® MotionBuilder® / Open Reality / FBPropertyPublish and custom Get and Set functions
  RSS 2.0 ATOM  

FBPropertyPublish and custom Get and Set functions
Rate this thread
 
57696
 
Permlink of this thread  
avatar
  • Total Posts: 2
  • Joined: 06 July 2011 09:33 AM

Hello,

I’m having an issue with being able to publish properties on a constraint using custom get and set function and I would like to know if anyone else encountered that issue, with possibly a solution.

In my case, I’m trying to publish a FBPropertyString on a constraint using the FBPropertyPublish macro and defines my own set and get function. However, I’m getting really weird result and the text that will be published seems to suffer from an undefined behavior issue. More precisely, after I set some text in the text box, the text quickly get modified with various character just like it would try to write from some random location in memory.

Here is an example of the code:

// In the header file, this would be defined
FBPropertyString SampleString;

static 
void SetSampleString(HIObject pObjectcharsampleStringText);
static 
charGetSampleString(HIObject pObject);

// In the FBCreate() function
FBPropertyPublish(thisSampleString"SampleString"GetSampleStringSetSampleString);

// The get and set functions implementation
void SetSampleString(HIObject pObjectcharsampleStringText)
{
    
// Do some stuff
    
FBCast<MyConstraint>(pObject)->SampleString.SetPropertyValue(sampleStringText);
)

charGetSampleString(HIObject)
{
    
return FBCast<MyConstraint>(pObject)->SampleString.GetPropertyValue();
}

Note also that I have been trying to do the same with FBPropertyDouble or FBPropertyInt and also got strange behavior or MotionBuilder crash. I’m currently working on MotionBuilder 2010, 32-bit.

Thank you very much for any help you could provide,
Marc-André



Replies: 0
avatar
  • Neill3d
  • Posted: 06 July 2011 08:25 AM

Hi,

I have found that it’s better not to use custom callbacks for properties (for string first of all), like this

FBPropertyPublishthisFileName"FileName"NULLNULL );

But I’m using custom callbacks also, for double, int, bool, action types

static int RigidBody_GetMinPointCount(HIObject object{
 CEModelRigidBody 
*rigidbody FBCast<CEModelRigidBody>(object);
 if (
rigidbody{
 RigidOptions
lOptions = (RigidOptions*) (TrackableOptions*) rigidbody->Options;
 return 
lOptions->minPointCount;
 
}
 
return 0;
}
static void RigidBody_SetMinPointCount(HIObject objectint value{
 CEModelRigidBody 
*rigidbody FBCast<CEModelRigidBody>(object);
 if ( 
rigidbody {
 RigidOptions
lOptions = (RigidOptions*) (TrackableOptions*) rigidbody->Options;
 
lOptions->minPointCount value;
 
}
}

//
// in class constructor
//

FBClassInit;

// then publish
FBPropertyPublishthisMinPointCount"Min Point Count"RigidBody_GetMinPointCountRigidBody_SetMinPointCount );


Replies: 0
avatar

Thank you very much for the information. It’s nice to know that I’m not crazy and there is actually something not working very well with the string. I’ll find a work around for this part!

Thank you,
Marc-André



Replies: 1
/img/forum/dark/default_avatar.png

I have several records about properties in orsdk on my blog, if you would like to read them

http://neill3d.com/en/a-little-bit-more-about-properties
http://neill3d.com/en/or-sdk-about-fbpropertyenum-fbpropertyaction

Best regards, Sergey Solohin (Neill3d)

Author: Neill3d

Replied: 08 July 2011 02:24 AM