Skip to content

Instantly share code, notes, and snippets.

@Neill3d
Neill3d / ORSDK_CreateAndDeleteConstraint
Last active August 29, 2015 14:09
MoBu OR SDK: working with constraint
// two ways for constraint creation
//
/// 1 - make it from constraint manager and show up in the scene constraints
pConstraint = FBConstraintManager::TheOne().TypeCreateConstraint( "Some constraint" );
/// 2 - make it for internal use (hiden from users)
pConstraint = new FBSomeConstraint( constraintName );
@Neill3d
Neill3d / IsPowerOfTwo
Created November 26, 2014 15:01
nice code example for checking if value is power of two
/**
* @fn IsPowerOfTwo(int n)
* @brief Returns true if /param n is an integer power of 2.
*
* Taken from Steve Baker's Cute Code Collection.
* http://www.sjbaker.org/steve/software/cute_code.html
*/
static bool IsPowerOfTwo(int n) { return ((n&(n-1))==0); }
@Neill3d
Neill3d / renderToFBO
Created February 16, 2015 15:39
Run an offline renderer
// on some create
mRenderer = new FBRenderer(0);
FBViewingOptions *pViewingOptions = mRenderer->GetViewingOptions();
pViewingOptions->PickingMode() = kFBPickingModeModelsOnly;
pViewingOptions->ShadingMode() = kFBModelShadingAll;
pViewingOptions->ShowTimeCode() = false;
pViewingOptions->ShowCameraLabel() = false;
@Neill3d
Neill3d / gist:a47bab01c0279d9244c3
Created February 18, 2015 15:14
iterate through enum class in Python
#Get the effector node id
for k, v in FBEffectorId.names.iteritems():
print v
@Neill3d
Neill3d / mobu_HWND
Created May 14, 2015 11:03
Sample showing how to catch MotionBuilder window handle
char windowTitle[128];
HWND FindInParent(HWND wnd)
{
if (wnd == nullptr)
return nullptr;
GetWindowText( wnd, windowTitle, 128 );
if (strstr( windowTitle, "MotionBuilder" ) != nullptr )
@Neill3d
Neill3d / gist:6682005
Last active December 23, 2015 19:19
MotionBuilder SDK Snippet - get pointer to a geometry model from the constraint input node
if( mSourceTranslation && mConstrainedTranslation )
{
FBComponent *pComp = nullptr;
int count = mSourceTranslation->GetSrcCount();
if (count)
{
pComp = (FBComponent*) mSourceTranslation->GetSrc(0)->GetOwner();
}
@Neill3d
Neill3d / gist:7582093
Last active December 28, 2015 23:49
MotionBuilder - making custom property view for your plugin
//I took that from HIK example
// 1 - in header declare some static procedure
static void AddPropertiesToPropertyViewManager();
// 2 - in source implement your custom view set
// where ORCONSTRAINTEXTRACTION__CLASSSTR - is your plugin class name
//
// you can add some folders and pack there your plugin properties
//
@Neill3d
Neill3d / gist:7667826
Created November 26, 2013 22:58
MotionBuilder Python: How to find a parent track for given story clip
from pyfbsdk import *
lStory = FBStory()
for lTrack in lStory.RootFolder.Tracks:
for lClip in lTrack.Clips:
print lClip.Name
if len(lClip.Parents):
for lParent in lClip.Parents:
print lParent.Name
@Neill3d
Neill3d / gist:8159117
Created December 28, 2013 12:38
OR SDK Constraint without input node
// NOTE:
// Usually input animation node should be assigned to constrained object,
// but this plug-in create an animation node which assigned to «Camera Switcher» to solve this constraint
// before other types of constraints such as ‘Path constraint’
// beacuse MotionBuilder dones’t have deformer propagation system.
if ( FBFindModelByName( »Camera Switcher» ) ){
mDummy_AnimationNode = AnimationNodeInCreate ( 0/*Curve_UserId*/, FBFindModelByName( »Camera Switcher» ), ANIMATIONNODE_TYPE_TRANSLATION );
@Neill3d
Neill3d / gist:8177642
Created December 30, 2013 03:58
Take care about model pointer in OR SDK (MotionBuilder)
//
// 1 - desclare pointer to a model with special class
//
HdlFBPlugTemplate<FBModel> mHdlModel;
//
// 2 - use it and check if pointer is actual
//