Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / gist:eeebdb9cdf800995bb1257c35f5078e6
Created May 16, 2017 15:19
MotionBuilder FBTime GetTimeString/SetTimeString Issue
lTime = FBTime(0,0,0,-1710)
strValue = lTime.GetTimeString()
print strValue
lTime2 = FBTime(0)
lTime2.SetTimeString(strValue)
frameIdx = lTime2.GetFrame()
@Neill3d
Neill3d / gist:fee0f3c4ab42f2c2f938de26a7749199
Created June 30, 2017 19:53
OR SDK: take information about blendshapes
/*
super important to initialize oriIndex variable with value like 0.
Othewise ShapeGetDiffPoint will not work and return false !!!
*/
int oriIndex=0;
FBVertex posDiff;
FBNormal normalDiff;
pGeometry->ShapeGetDiffPoint(i, j, oriIndex, posDiff, normalDiff);
@Neill3d
Neill3d / gist:1a57cdca9493493b98ba59fe9aeca207
Created July 30, 2017 09:41
Binding vertex attributes from FBModelVertexData
// don't forget to check for VBO offsets
FBModelVertexData *pVertexData = pModel->ModelVertexData;
if (pVertexData == nullptr || pVertexData->IsDrawable() == false)
return false;
const unsigned int positionId = pVertexData->GetVertexArrayVBOId(kFBGeometryArrayID_Point);
const unsigned int normalId = pVertexData->GetVertexArrayVBOId(kFBGeometryArrayID_Normal );
const unsigned int uvId = pVertexData->GetUVSetVBOId();
@Neill3d
Neill3d / gist:38ffd8cbf2f7c736554907d4b7805b77
Created July 21, 2018 15:43
Life checkers for FBModelList and FBComponentList
struct SComponentListHolder
{
public:
// a constructor
SComponentListHolder()
{
component_list = FBCreateComponentList();
}
~SComponentListHolder()
{
@Neill3d
Neill3d / gist:9f20ed65b38db1731c33942c0fe7c6b3
Created April 14, 2019 22:42
MoBu Embedded Code Device
# script is running inside the same context, so it could be splitted into initialization step and evaluation step
# here is an example
try:
initialize > 0
print "evaluating"
except (NameError,),e:
initialize = 1
print "initilize"