|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| FBPropertyPublish and custom Get and Set functions
|
|
|
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 pObject, char* sampleStringText);
static char* GetSampleString(HIObject pObject);
// In the FBCreate() function FBPropertyPublish(this, SampleString, "SampleString", GetSampleString, SetSampleString);
// The get and set functions implementation void SetSampleString(HIObject pObject, char* sampleStringText) {
// Do some stuff
FBCast<MyConstraint>(pObject)->SampleString.SetPropertyValue(sampleStringText);
)
char* GetSampleString(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é
|
|
|
|
Hi,
I have found that it’s better not to use custom callbacks for properties (for string first of all), like this
FBPropertyPublish( this, FileName, "FileName", NULL, NULL );
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 object, int value) {
CEModelRigidBody *rigidbody = FBCast<CEModelRigidBody>(object);
if ( rigidbody ) {
RigidOptions* lOptions = (RigidOptions*) (TrackableOptions*) rigidbody->Options;
lOptions->minPointCount = value;
}
}
//
// in class constructor
//
FBClassInit;
// then publish FBPropertyPublish( this, MinPointCount, "Min Point Count", RigidBody_GetMinPointCount, RigidBody_SetMinPointCount );
|
|
|
|
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é
|
|
|
|
|
|