boxes/boxhmfstotc/orboxhmsftotc_box.cxx

boxes/boxhmfstotc/orboxhmsftotc_box.cxx
/***************************************************************************************
Autodesk(R) Open Reality(R) Samples
(C) 2009 Autodesk, Inc. and/or its licensors
All rights reserved.
AUTODESK SOFTWARE LICENSE AGREEMENT
Autodesk, Inc. licenses this Software to you only upon the condition that
you accept all of the terms contained in the Software License Agreement ("Agreement")
that is embedded in or that is delivered with this Software. By selecting
the "I ACCEPT" button at the end of the Agreement or by copying, installing,
uploading, accessing or using all or any portion of the Software you agree
to enter into the Agreement. A contract is then formed between Autodesk and
either you personally, if you acquire the Software for yourself, or the company
or other legal entity for which you are acquiring the software.
AUTODESK, INC., MAKES NO WARRANTY, EITHER EXPRESS OR IMPLIED, INCLUDING BUT
NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
PURPOSE REGARDING THESE MATERIALS, AND MAKES SUCH MATERIALS AVAILABLE SOLELY ON AN
"AS-IS" BASIS.
IN NO EVENT SHALL AUTODESK, INC., BE LIABLE TO ANYONE FOR SPECIAL, COLLATERAL,
INCIDENTAL, OR CONSEQUENTIAL DAMAGES IN CONNECTION WITH OR ARISING OUT OF PURCHASE
OR USE OF THESE MATERIALS. THE SOLE AND EXCLUSIVE LIABILITY TO AUTODESK, INC.,
REGARDLESS OF THE FORM OF ACTION, SHALL NOT EXCEED THE PURCHASE PRICE OF THE
MATERIALS DESCRIBED HEREIN.
Autodesk, Inc., reserves the right to revise and improve its products as it sees fit.
Autodesk and Open Reality are registered trademarks or trademarks of Autodesk, Inc.,
in the U.S.A. and/or other countries. All other brand names, product names, or
trademarks belong to their respective holders.
GOVERNMENT USE
Use, duplication, or disclosure by the U.S. Government is subject to restrictions as
set forth in FAR 12.212 (Commercial Computer Software-Restricted Rights) and
DFAR 227.7202 (Rights in Technical Data and Computer Software), as applicable.
Manufacturer is Autodesk, Inc., 10 Duke Street, Montreal, Quebec, Canada, H3C 2L7.
***************************************************************************************/
//--- Class declaration
#include "orboxhmsftotc_box.h"
//--- Registration defines
#define ORBOXHMFS_TO_TC23976__CLASS ORBOXHMFS_TO_TC23976__CLASSNAME
#define ORBOXHMFS_TO_TC23976__NAME ORBOXHMFS_TO_TC23976__CLASSSTR
#define ORBOXHMFS_TO_TC23976__LOCATION "Converters"
#define ORBOXHMFS_TO_TC23976__LABEL "HMSF to TimeCode 23.976"
#define ORBOXHMFS_TO_TC23976__DESC "HMSF to TimeCode 23.976"
//--- implementation and registration
FBBoxImplementation ( ORBOXHMFS_TO_TC23976__CLASS ); // Box class name
FBRegisterBox ( ORBOXHMFS_TO_TC23976__NAME, // Unique name to register box.
ORBOXHMFS_TO_TC23976__CLASS, // Box class name
ORBOXHMFS_TO_TC23976__LOCATION, // Box location ('Converters')
ORBOXHMFS_TO_TC23976__LABEL, // Box label (name of box to display)
ORBOXHMFS_TO_TC23976__DESC, // Box long description.
FB_DEFAULT_SDK_ICON ); // Icon filename (default=Open Reality icon)
/************************************************
* Creation
************************************************/
bool ORBoxHMSF_to_TC23976::FBCreate()
{
if( FBBox::FBCreate() )
{
// Create the input nodes.
mHMSF[0] = AnimationNodeInCreate( 1, "1_H", ANIMATIONNODE_TYPE_NUMBER );
mHMSF[1] = AnimationNodeInCreate( 1, "2_M", ANIMATIONNODE_TYPE_NUMBER );
mHMSF[2] = AnimationNodeInCreate( 1, "3_S", ANIMATIONNODE_TYPE_NUMBER );
mHMSF[3] = AnimationNodeInCreate( 1, "4_F", ANIMATIONNODE_TYPE_NUMBER );
// Create the output node.
mTC = AnimationNodeOutCreate ( 0, "TC23_976", ANIMATIONNODE_TYPE_TIMECODE );
return true;
}
return false;
}
/************************************************
* Destruction.
************************************************/
void ORBoxHMSF_to_TC23976::FBDestroy()
{
FBBox::FBDestroy();
}
/************************************************
* Real-time engine evaluation
************************************************/
bool ORBoxHMSF_to_TC23976::AnimationNodeNotify( FBAnimationNode* pAnimationNode, FBEvaluateInfo* pEvaluateInfo )
{
double lHMSF[4];
bool lStatus[5]; // Status of input node
// Read the input nodes.
lStatus[0] = mHMSF[0]->ReadData( &lHMSF[0], pEvaluateInfo );
lStatus[1] = mHMSF[1]->ReadData( &lHMSF[1], pEvaluateInfo );
lStatus[2] = mHMSF[2]->ReadData( &lHMSF[2], pEvaluateInfo );
lStatus[3] = mHMSF[3]->ReadData( &lHMSF[3], pEvaluateInfo );
lStatus[4] = lStatus[0] && lStatus[1] && lStatus[2] && lStatus[3] ;
// If the read was not from a dead node.
if( lStatus[4] )
{
double lWrite[3];
lWrite[0] = lHMSF[0]*60*60+lHMSF[1]*60+lHMSF[2]; //seconds
lWrite[1] = lHMSF[3]; //frames
lWrite[2] = FBTimeCode::FILM_23976; //rate
// Write the tc.
mTC->WriteData( lWrite, pEvaluateInfo );
return true;
}
return false;
}