tools/toolview3d/ortoolview3d_tool.cxx

tools/toolview3d/ortoolview3d_tool.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 "ortoolview3d_tool.h"
//--- Registration defines
#define ORTOOLVIEW3D__CLASS ORTOOLVIEW3D__CLASSNAME
#define ORTOOLVIEW3D__LABEL "View3D"
#define ORTOOLVIEW3D__DESC "OR - 3D Viewer Tool"
//--- Implementation and registration
FBToolImplementation( ORTOOLVIEW3D__CLASS );
FBRegisterTool ( ORTOOLVIEW3D__CLASS,
ORTOOLVIEW3D__LABEL,
ORTOOLVIEW3D__DESC,
FB_DEFAULT_SDK_ICON ); // Icon filename (default=Open Reality icon)
/************************************************
* Constructor.
************************************************/
bool ORToolView3D::FBCreate()
{
StartSize[0] = 300;
StartSize[1] = 300;
// Manage UI
UICreate ();
UIConfigure ();
UIReset ();
// Add tool callbacks
OnShow.Add ( this, (FBCallback) &ORToolView3D::EventToolShow );
OnIdle.Add ( this, (FBCallback) &ORToolView3D::EventToolIdle );
OnResize.Add( this, (FBCallback) &ORToolView3D::EventToolResize );
OnPaint.Add ( this, (FBCallback) &ORToolView3D::EventToolPaint );
OnInput.Add ( this, (FBCallback) &ORToolView3D::EventToolInput );
return true;
}
/************************************************
* Create, configure & reset UI.
************************************************/
void ORToolView3D::UICreate()
{
// Tool options
int lS = 4;
// Configure layout
AddRegion( "LabelDirections", "LabelDirections",
lS, kFBAttachLeft, "", 1.0 ,
lS, kFBAttachTop, "", 1.0,
-lS,kFBAttachRight, "", 1.0,
30, kFBAttachNone, "", 1.0 );
AddRegion( "View3D", "View3D",
lS, kFBAttachLeft, "", 1.0,
lS, kFBAttachBottom,"LabelDirections", 1.0,
-lS,kFBAttachRight, "",1.0,
-lS,kFBAttachBottom,"",1.0 );
// Assign regions
SetControl ( "LabelDirections", mLabelDirections );
SetView ( "View3D", mView );
}
void ORToolView3D::UIConfigure()
{
mLabelDirections.Caption = "This is a demonstration of the FBView UI element and\n"
"the FBRenderer class for viewing the 3D scene.";
}
void ORToolView3D::UIReset()
{
}
/************************************************
* Destruction function.
************************************************/
void ORToolView3D::FBDestroy()
{
// Remove tool callbacks
OnShow.Remove ( this, (FBCallback) &ORToolView3D::EventToolShow );
OnIdle.Remove ( this, (FBCallback) &ORToolView3D::EventToolIdle );
OnPaint.Remove ( this, (FBCallback) &ORToolView3D::EventToolPaint );
OnInput.Remove ( this, (FBCallback) &ORToolView3D::EventToolInput );
OnResize.Remove ( this, (FBCallback) &ORToolView3D::EventToolResize );
// Free user allocated memory
}
/************************************************
* UI Idle callback.
************************************************/
void ORToolView3D::EventToolIdle( HISender pSender, HKEvent pEvent )
{
RefreshView();
}
void ORToolView3D::RefreshView()
{
mView.Refresh(true);
}
/************************************************
* Handle tool activation (selection/unselection).
************************************************/
void ORToolView3D::EventToolShow( HISender pSender, HKEvent pEvent )
{
FBEventShow lEvent( pEvent );
if( lEvent.Shown )
{
// Reset the UI here.
}
else
{
}
}
/************************************************
* Paint callback for tool (on expose).
************************************************/
void ORToolView3D::EventToolPaint( HISender pSender, HKEvent pEvent )
{
}
/************************************************
* Tool resize callback.
************************************************/
void ORToolView3D::EventToolResize( HISender pSender, HKEvent pEvent )
{
}
/************************************************
* Handle input into the tool.
************************************************/
void ORToolView3D::EventToolInput( HISender pSender, HKEvent pEvent )
{
}
/************************************************
* FBX Storage.
************************************************/
bool ORToolView3D::FbxStore ( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat )
{
pFbxObject->FieldWriteBegin( "ORToolView3DSection" );
{
}
pFbxObject->FieldWriteEnd();
return true;
}
/************************************************
* FBX Retrieval.
************************************************/
bool ORToolView3D::FbxRetrieve( FBFbxObject* pFbxObject, kFbxObjectStore pStoreWhat )
{
pFbxObject->FieldReadBegin( "ORToolView3DSection" );
{
}
pFbxObject->FieldReadEnd();
return true;
}