Skip to content

Instantly share code, notes, and snippets.

@Neill3d
Neill3d / FbxStoreRetrieve
Created May 11, 2016 20:23
Tip about motionbuilder store retrieve
// In SDK samples in most cases, store and retrive use this kind of condition
if( pStoreWhat == kAttributes )
{
//...
}
// This is not correct, cause kAttributes is a bit flag and it could be used with kMerge (in merge pass)
// So better to use this kind of condition instead
@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: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 / 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 / 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 / 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 / ORSDK_FBTexture_GetImage
Last active August 29, 2015 14:05
FBTexture GetImage() method
// Regarding to the image data and FBTexture class in OR SDK (MotionBuilder)
// In theory you are able to put image frame index direcly to that GetImage method
// that should return GLubyte *data of a specified frame
// but in practive it will produce error for future MoBu drawing
// the way out is to...
// 1 - first of all, specify the current frame with "CurrentFrame" property
// 2 - execute GetImage() function with a argument -1 by default
@Neill3d
Neill3d / ORSDK_ConvertFBVideoFormat
Last active August 29, 2015 14:05
Convert OR SDK image clip format to opengl format
const FBVideoFormat clipFormat = (pVideoClip) ? (pVideoClip->Format) : kFBVideoFormat_RGB_24;
GLint internalFormat = (compressed) ? GL_COMPRESSED_RGB : GL_RGB;
GLint format = GL_RGB;
switch (clipFormat)
{
case kFBVideoFormat_Any:
printf( "%s - unsupported video format\n", pVideoClip->Name );
break;
@Neill3d
Neill3d / ORSDK_CurrentCamera_And_Switcher
Last active August 29, 2015 14:05
OR SDK: current rendering camera (don't forget about camera switcher)
// FBRenderOptions *pOptions
FBCamera *pCamera = pOptions->GetRenderingCamera();
if ( FBIS(pCamera, FBCameraSwitcher) )
pCamera = ((FBCameraSwitcher*) pCamera)->CurrentCamera;
@Neill3d
Neill3d / ORSDK_MeshIndices
Last active August 29, 2015 14:01
VBO Render Indices in the MoBu model
// Even if the function returns to us integers (in the FBModelVertexData class)
/** Return Index Array*/
int* GetIndexArray();
// you should remember that VBO buffer type of an element is unsigned int
// draw all model sub patches
for (int i=0; i<lVertexData->GetSubPatchCount(); ++i)
{