Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Neill3d
Neill3d / ORSDK_ConfigFile
Last active August 29, 2015 13:56
MoBu OR SDK: how to work with config file
FBConfigFile lFile( "@MyConfig.txt", true );
FBString strDefault( "false" );
const char *szDefault = strDefault;
lFile.GetOrSet( "MyCategory", "MyParameter", szDefault, "This is default comment on parameter, value (true / false)" );
return ( strstr(szDefault, "true") != nullptr );
@Neill3d
Neill3d / ORSDK_PopupMenu
Last active August 29, 2015 13:59
OR SDK (MoBu) Popup a generic menu from button click
// declare a generic menu
FBGenericMenu mPopupMenu;
// populate the menu
mPopupMenu.InsertLast( "Menu Item 1", 0 );
mPopupMenu.InsertLast( "Menu Item 2", 1 );
mPopupMenu.InsertLast( "Menu Item 3", 2 );
@Neill3d
Neill3d / nvFX_code
Last active August 29, 2015 13:59
nvFX - how to directly override shader in pass
nvFX::IShader *shdPtr = fx_EffectMaterial->findShader( "SomeShader2" );
if (shdPtr)
{
// lets override current shader in the first pass of specified technique
fx_pass = fx_TechMaterial->getPass(0);
fx_pass->invalidate();
// Nnnn 1 - directly override shaders
@Neill3d
Neill3d / ORSDK_RelationBox2FBModel
Last active August 29, 2015 13:59
Get FBModel class pointer from a relation box
// Create the input node.
mNodeMesh = AnimationNodeInCreate( 0, "Mesh", ANIMATIONNODE_TYPE_VECTOR );
// ...
/************************************************
* Real-time engine evaluation
************************************************/
bool Box_RayIntersect::AnimationNodeNotify( HFBAnimationNode pAnimationNode, HFBEvaluateInfo pEvaluateInfo )
{
@Neill3d
Neill3d / nvFX_GetGLSL_program
Last active August 29, 2015 13:59
nvFX: how to get glsl program object id
int program = 0;
nvFX::IProgram *glslProgram = nullptr;
nvFX::IProgramPipeline *glslProgramPipeline = fx_pass->getExInterface()->getProgramPipeline(0);
// program pipeline means that we are using separate shader objects
if(glslProgramPipeline)
{
glslProgram = glslProgramPipeline->getShaderProgram(1); // Fragment glsl program in program pipeline !
@Neill3d
Neill3d / MoBu_FIX4Lighting_Cg_Shader
Last active August 29, 2015 14:00
LightingPS.cg in the MoBu Dynamic Lighting shader
// To make the spot light works in correct way with normal maps assigned on meshes, you should change lines to these one
// And last but not least, figure out the spot factor ...
float spotFactor = 1.0f;
if( LightPositions[index].w )
{
float3 spotLightDir = normalize(LightDirections[index].xyz);
//spotLightDir = mul(fTangentMat, spotLightDir);
spotFactor = saturate( (dot( -normalize(lightDiff), -spotLightDir ) - LightDirections[index].w) / (1 - LightDirections[index].w) );
}
@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)
{
@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_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_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