Skip to content

Instantly share code, notes, and snippets.

Avatar

Sergei Solokhin Neill3d

View GitHub Profile
View gist:102d6c5cc0a67dd776306bcc06959bae
import traceback
import StringIO
import logging
import os, sys
from pyfbsdk import *
def print_to_hud(text):
printed = False
View gist:9f20ed65b38db1731c33942c0fe7c6b3
# 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"
@Neill3d
Neill3d / gist:38ffd8cbf2f7c736554907d4b7805b77
Created Jul 21, 2018
Life checkers for FBModelList and FBComponentList
View gist:38ffd8cbf2f7c736554907d4b7805b77
struct SComponentListHolder
{
public:
// a constructor
SComponentListHolder()
{
component_list = FBCreateComponentList();
}
~SComponentListHolder()
{
@Neill3d
Neill3d / gist:1a57cdca9493493b98ba59fe9aeca207
Created Jul 30, 2017
Binding vertex attributes from FBModelVertexData
View gist:1a57cdca9493493b98ba59fe9aeca207
// 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:fee0f3c4ab42f2c2f938de26a7749199
Created Jun 30, 2017
OR SDK: take information about blendshapes
View gist:fee0f3c4ab42f2c2f938de26a7749199
/*
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:eeebdb9cdf800995bb1257c35f5078e6
Created May 16, 2017
MotionBuilder FBTime GetTimeString/SetTimeString Issue
View gist:eeebdb9cdf800995bb1257c35f5078e6
lTime = FBTime(0,0,0,-1710)
strValue = lTime.GetTimeString()
print strValue
lTime2 = FBTime(0)
lTime2.SetTimeString(strValue)
frameIdx = lTime2.GetFrame()
@Neill3d
Neill3d / FbxStoreRetrieve
Created May 11, 2016
Tip about motionbuilder store retrieve
View FbxStoreRetrieve
// 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
Sample showing how to catch MotionBuilder window handle
View mobu_HWND
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 Feb 18, 2015
iterate through enum class in Python
View gist:a47bab01c0279d9244c3
#Get the effector node id
for k, v in FBEffectorId.names.iteritems():
print v
@Neill3d
Neill3d / renderToFBO
Created Feb 16, 2015
Run an offline renderer
View renderToFBO
// on some create
mRenderer = new FBRenderer(0);
FBViewingOptions *pViewingOptions = mRenderer->GetViewingOptions();
pViewingOptions->PickingMode() = kFBPickingModeModelsOnly;
pViewingOptions->ShadingMode() = kFBModelShadingAll;
pViewingOptions->ShowTimeCode() = false;
pViewingOptions->ShowCameraLabel() = false;