fbsdk/fbrenderer.h Source File

fbrenderer.h
Go to the documentation of this file.
1 #ifndef __FBRENDERER_H__
2 #define __FBRENDERER_H__
3 /**************************************************************************
4 Copyright (c) 1994 - 2009 Autodesk, Inc. and/or its licensors.
5 All Rights Reserved.
6 
7 The coded instructions, statements, computer programs, and/or related
8 material (collectively the "Data") in these files contain unpublished
9 information proprietary to Autodesk, Inc. and/or its licensors, which is
10 protected by Canada and United States of America federal copyright law
11 and by international treaties.
12 
13 The Data may not be disclosed or distributed to third parties, in whole
14 or in part, without the prior written consent of Autodesk, Inc.
15 ("Autodesk").
16 
17 THE DATA IS PROVIDED "AS IS" AND WITHOUT WARRANTY.
18 ALL WARRANTIES ARE EXPRESSLY EXCLUDED AND DISCLAIMED. AUTODESK MAKES NO
19 WARRANTY OF ANY KIND WITH RESPECT TO THE DATA, EXPRESS, IMPLIED OR
20 ARISING BY CUSTOM OR TRADE USAGE, AND DISCLAIMS ANY IMPLIED WARRANTIES
21 OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR
22 PURPOSE OR USE. WITHOUT LIMITING THE FOREGOING, AUTODESK DOES NOT
23 WARRANT THAT THE OPERATION OF THE DATA WILL BE UNINTERRUPTED OR ERROR
24 FREE.
25 
26 IN NO EVENT SHALL AUTODESK, ITS AFFILIATES, PARENT COMPANIES, LICENSORS
27 OR SUPPLIERS ("AUTODESK GROUP") BE LIABLE FOR ANY LOSSES, DAMAGES OR
28 EXPENSES OF ANY KIND (INCLUDING WITHOUT LIMITATION PUNITIVE OR MULTIPLE
29 DAMAGES OR OTHER SPECIAL, DIRECT, INDIRECT, EXEMPLARY, INCIDENTAL, LOSS
30 OF PROFITS, REVENUE OR DATA, COST OF COVER OR CONSEQUENTIAL LOSSES OR
31 DAMAGES OF ANY KIND), HOWEVER CAUSED, AND REGARDLESS OF THE THEORY OF
32 LIABILITY, WHETHER DERIVED FROM CONTRACT, TORT (INCLUDING, BUT NOT
33 LIMITED TO, NEGLIGENCE), OR OTHERWISE, ARISING OUT OF OR RELATING TO THE
34 DATA OR ITS USE OR ANY OTHER PERFORMANCE, WHETHER OR NOT AUTODESK HAS
35 BEEN ADVISED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGE.
36 
37 **************************************************************************/
38 
43 #include <kaydaradef.h>
44 #ifndef FBSDK_DLL
45 
48 #define FBSDK_DLL K_DLLIMPORT
49 #endif
50 
51 #if !defined(K_NO_MANIPULATOR)
52 #include <fbsdk/fbmanipulator.h>
53 #endif
54 
55 #include <fbsdk/fbcomponent.h>
56 #include <fbsdk/fbmodel.h>
57 #include <fbsdk/fbcamera.h>
58 #include <fbsdk/fblight.h>
59 #include <fbsdk/fbshader.h>
60 #include <fbcontrols/fbcontrols.h> // FBInputType
61 
62 #ifdef FBSDKUseNamespace
63 namespace FBSDKNamespace {
64 #endif
65 
66  __FB_FORWARD( FBRenderer );
67  __FB_FORWARD( FBRendererCallback );
68 
69  FB_FORWARD( FBView );
70 
72 
74 
83  };
84 
87  enum FBArrangeMode {
90  };
91 
93  {
105  };
106 
108 
113  kFBDisplayNull = (1 << 0),
114  kFBDisplayMarker = (1 << 1),
115  kFBDisplaySkeleton = (1 << 2),
116  kFBDisplayCenter = (1 << 3),
117  kFBDisplayLight = (1 << 4),
118  kFBDisplayCamera = (1 << 5),
119  kFBDisplay3dIcon = (1 << 6),
121  };
122 
124 
130  };
131 
133 
168  };
169 
170  FB_DEFINE_ENUM( FBSDK_DLL, DeviceKeyboardKey );
171 
176  {
177  public:
180  FBCamera* GetViewingCamera();
181 
185  FBModelShadingMode& ShadingMode();
186 
190  FBStereoDisplayMode& StereoDisplayMode();
191 
195  int& DisplayWhat();
196 
200  FBPickingMode& PickingMode();
201 
204  bool& ShowTimeCode();
205 
208  bool& ShowSafeArea();
209 
212  bool& ShowCameraLabel();
213 
217  K_DEPRECATED_2014 bool InPicking() const;
218 
221  bool IsInSelectionBufferPicking() const;
222 
225  bool IsInColorBufferPicking() const;
226 
229  unsigned int RenderCallbackPrefIndex() const;
230 
234  int PaneIndex() const;
235 
236  private:
239  FBViewingOptions & operator =(const FBViewingOptions &);
240  };
241 
242 
244  // FBPickInfos
246 
275  struct FBPickInfos
276  {
283  FBPickInfos( FBModel* pModel, FBVector3d pPoint, FBVector3d pNormal, int pSubItemIndex )
284  : mModel( pModel ), mPoint( pPoint ), mNormal (pNormal), mSubItemIndex(pSubItemIndex) {};
285 
286  FBModel* mModel;
290  };
291 
292  bool operator==( const FBPickInfos& pLhs, const FBPickInfos& pRhs );
293 
296 
304 
308  FBSDK_DLL void FBDestroyPickInfosList( FBPickInfosList* pPickInfosList );
309 
311  // FBRendererCallback
313 
316  {
317  //--- Open Reality declaration.
319  public:
320 
323  FBRendererCallback(const char* pName);
324 
328  virtual const char* GetCallbackName() const = 0;
329 
334  virtual const char* GetCallbackDesc() const = 0;
335 
341  virtual unsigned int GetCallbackPrefCount() const;
342 
346  virtual const char* GetCallbackPrefName(unsigned int pIndex) const;
347 
351  virtual void Render(FBRenderOptions* pRenderOptions);
352 
356  virtual void Attach();
357 
361  virtual void Detach();
362 
368  virtual void DetachDisplayContext(FBViewingOptions* pViewOption);
369 
375  };
376 
377  FB_DEFINE_COMPONENT ( FBSDK_DLL, RendererCallback );
378 
386 #define FBRegisterRendererCallback( UniqueNameStr, ClassName, Label, Description, IconFilename ) \
387  HIObject CreateRendererCallback##ClassName( HIObject /*pOwner*/,const char* pName,void * /*pData*/) \
388  { \
389  ClassName *Class = new ClassName( pName ); \
390  if (Class->FBCreate()) { \
391  return Class->GetHIObject(); \
392  } else { \
393  delete Class; \
394  return NULL; \
395  } \
396  } \
397  FBLibraryModule( ClassName ) \
398  { \
399  FBRegisterObject( ClassName##R1,"renderer/callback/ogl",Label,Description,CreateRendererCallback##ClassName,true, IconFilename ); \
400  }
401 
406 #define FBRendererCallbackDeclare( ClassName, Parent ) \
407  FBClassDeclare( ClassName,Parent); \
408 public: \
409  ClassName(const char* pName):Parent(pName) { FBClassInit; } \
410 private:
411 
415 #define FBRendererCallbackImplementation( ThisComponent ) \
416  FBClassImplementation( ThisComponent )
417 
418 
420  // FBPropertyListRendererCallback
423 
425  {
426  public:
434  virtual int Add( FBRendererCallback* pItem );
439  FBRendererCallback* operator[](int pIndex);
440 
441  private:
442  inline virtual int Add ( FBComponent* pItem ) { return Add((FBRendererCallback*)pItem); }
443  };
444 
446  // FBRenderer
448 
451  {
452  //--- Open Reality declaration.
454  public:
460  FBRenderer(HIObject pObject);
461 
462  //--- Rendering manipulation
470  void SetViewport(int pX,int pY,int pW,int pH);
471 
481  bool RenderBegin(int pX,int pY,int pW,int pH);
482 
488  bool RenderEnd(FBView* pView=NULL);
489 
502  bool PreRender(int pLayer = -1);
503 
508  bool Render(int pLayer = -1);
509 
513  void OGLSetupSceneLights(FBRenderOptions& pRenderOptions);
514 
520  void OGLModelDisplay(FBRenderOptions& pRenderOptions, FBModel& pModel);
521 
525  bool SetViewingOptions(FBViewingOptions & pOptions);
526 
530  FBViewingOptions * GetViewingOptions();
531 
536  bool FrameCurrentCameraWithModels(bool pAll);
537 
539  void ArrangeSelectedObjectsInSchematic();
540 
545  bool ArrangeObjectsInSchematicFromModel( const FBModel& pModel );
546 
550  void ArrangeAllInSchematic(FBArrangeMode pMode);
551 
560  bool GetSchematicNodesBoundingBox( bool pConsiderCollapsedNodes, int& pTop, int& pLeft, int& pBottom, int& pRight );
561 
571  bool GetSchematicNodesBoundingBoxFromModel( FBModel* pModel, bool pConsiderCollapsedNodes, int& pTop, int& pLeft, int& pBottom, int& pRight );
572 
573  //--- \internal Camera manipulation, Manipulators
584  bool MouseInput(int pX,int pY,FBInputType pInputType,int pButtonKey,FBInputModifier pModifier,int pWheelDeltaValue=0,int pLayer = -1);
585 
597  bool MouseInputNormalized(float pX,float pY,FBInputType pInputType,int pButtonKey,FBInputModifier pModifier,int pWheelDeltaValue, int pLayer = -1, int pPaneId = -1);
598 
606  bool Pick(int pX, int pY, FBPickInfosList& pPickInfosList, bool pNeedIntersectPosition = false );
607 
616  bool PickNormalized(float pX, float pY, FBPickInfosList& pPickInfosList, bool pNeedIntersectPosition = false, int pPaneId = -1);
617 
625  bool RectPick(int pX1, int pY1, int pX2, int pY2, FBPickInfosList& pPickInfosList);
626 
635  bool RectPickNormalized(float pX1, float pY1, float pX2, float pY2, FBPickInfosList& pPickInfosList, int pPaneId = -1);
636 
641  int GetLastPickInfoList(FBPickInfosList& pPickInfosList);
642 
648  void KeyboardInput(FBDeviceKeyboardKey pKeyIndex, bool pKeyState, bool pIsTrigger = false);
649 
655  FBModel* GetDisplayableGeometry(int pIndex );
656 
662  FBLight* GetDisplayableLight(int pIndex );
663 
673  const FBModelList& GetDisplayableGeometryInCameraFrustum(FBModelList* pModelList = NULL, FBCamera* pCamera = NULL);
674 
683  bool IsModelInsideCameraFrustum(FBModel* pGeometry, FBCamera* pCamera = NULL);
684 
685  // Properties
688 
689 #if !defined(K_NO_MANIPULATOR)
692 #endif
693 
716 
721 
734 
739  int GetViewerTextureId();
740 
744  void CloneViewAdd(FBView* pView);
745 
749  void CloneViewRemove(FBView* pView);
750 
755  void CloneViewRender(int pWidth, int pHeight);
756 
772  void SetCameraInPane( FBCamera* pCamera, unsigned int pPaneIndex );
773 
786  FBCamera* GetCameraInPane( unsigned int pPaneIndex );
787 
791  void SetPaneCount( unsigned int pPaneCount );
792 
796  unsigned int GetPaneCount();
797 
802  bool SetSelectedPaneIndex( unsigned int pPaneIndex );
803 
807  unsigned int GetSelectedPaneIndex() const;
808 
815  void SetSchematicViewInPane( unsigned int pPaneIndex, bool pActive );
816 
820  int GetSchematicViewPaneIndex();
821 
829  void SetCameraSwitcherInPane( unsigned int pPaneIndex, bool pActive );
830 
837  bool IsCameraSwitcherInPane( unsigned int pPaneIndex );
838  };
839 
840 #ifdef FBSDKUseNamespace
841 }
842 #endif
843 #endif /* this must be the last line of this file */
FBPropertyInt DisplayableLightCount
Read Only Property: Displayable light count.
Definition: fbrenderer.h:711
FBPropertyBool DefaultLightGroundProjectionRendering
Read write Property: Set true to use default light ground projection rendering; set false to disable ...
Definition: fbrenderer.h:373
class FBArrayTemplate< FBModel * > FBModelList
typedef class FBSDK_DLL FBArrayTemplate FBModelList;
Definition: fbcharacter.h:597
FBPropertyBool Background
Read Write Property: The renderer.
Definition: fbrenderer.h:697
FBPropertyBool SupportIDBufferPicking
Read write Property: Can this Renderer Callback support IDBuffer Picking.
Definition: fbrenderer.h:370
Model class.
Definition: fbmodel.h:273
#define __FBClassDeclare(Name, Parent)
For internal use only.
Definition: fbcomponent.h:132
Wire-frame rendering.
Definition: fbrenderer.h:81
Textures are displayed.
Definition: fbrenderer.h:78
Lights are displayed.
Definition: fbrenderer.h:117
Open Reality renderer interface.
Definition: fbrenderer.h:450
#define FB_DEFINE_COMPONENT(DllTag, Type)
Define a component and give it the ability to be a property.
Definition: fbproperties.h:139
Display in Center Eye Camera, No Stereo effect.
Definition: fbrenderer.h:94
int mSubItemIndex
Picked sub item index, -1 for whole object.
Definition: fbrenderer.h:289
class FBPropertyBaseComponent< FBCamera * > FBPropertyCamera
Definition: fbcamera.h:58
Nothing is displayed.
Definition: fbrenderer.h:112
Use default display mode.
Definition: fbrenderer.h:77
FBPropertyListRendererCallback RendererCallbacks
List: Renderer Callbacks attached.
Definition: fbrenderer.h:712
FBPropertyListManipulator Manipulators
List: of manipulators.
Definition: fbrenderer.h:691
FBPropertyBool AdvancedLightingMode
Read write Property: Turn on/off advanced lighting setting UI widgets.
Definition: fbrenderer.h:733
FBPropertyBool SelectionForceSnapPointsDisplay
Read write Property: Force show all feature points (pivots and etc) on selected models if true...
Definition: fbrenderer.h:707
class FBPropertyBase< double, kFBPT_double > FBPropertyDouble
Property: double
Markers are displayed.
Definition: fbrenderer.h:114
FBPropertyBool DefaultCameraBackPlateRendering
Read write Property: Set true to use default camera back plate rendering; set false to disable it...
Definition: fbrenderer.h:372
Arrange all objects horizontally.
Definition: fbrenderer.h:88
Everything is displayed.
Definition: fbrenderer.h:120
Creates custom cameras and manages system cameras.
Definition: fbcamera.h:206
#define NULL
Definition: kaydara.h:169
FBPropertyInt DisplayableGeometryCount
Read Only Property: Displayable geometry count.
Definition: fbrenderer.h:710
Viewing options for rendering.
Definition: fbrenderer.h:175
FBVector3d mNormal
Normal of the pick on the model's surface in world space.
Definition: fbrenderer.h:288
FBInputType
Types of input events.
Definition: fbcontrols.h:117
FBInputModifier
Input Modifiers (Ctrl, Alt, Shift).
Definition: fbcontrols.h:135
Generic view.
Definition: fbcontrols.h:1902
Display in Left Eye Caerma, No Stereo effect.
Definition: fbrenderer.h:95
Models-only mode (no nulls or skeletons are displayed).
Definition: fbrenderer.h:128
PropertyList: Manipulator.
Open Reality renderer callback interface.
Definition: fbrenderer.h:315
Base class for Cameras.
#define FB_DEFINE_ENUM(DllTag, Type)
Define an enum and give it the ability to be a property.
Definition: fbproperties.h:148
Display in parallel free view stereo mode.
Definition: fbrenderer.h:102
Contains the user interface components for the SDK.
Display in Right Eye Caerma, No Stereo effect.
Definition: fbrenderer.h:96
class FBPropertyBaseComponent< FBManipulatorTransform * > FBPropertyManipulatorTransform
MotionBuilder SDK base class.
Definition: fbcomponent.h:668
FBPropertyBool ShowStats
Read Write Property: Show the stats about FPS, Evaluation rate ...
Definition: fbrenderer.h:698
Skeletons and bones are displayed.
Definition: fbrenderer.h:115
FBPropertyBool UseCameraSwitcher
Definition: fbrenderer.h:687
Centers are displayed.
Definition: fbrenderer.h:116
class FBPropertyBase< bool, kFBPT_bool > FBPropertyBool
Property: bool
FBDisplayMode
Model display options.
Definition: fbrenderer.h:76
FBPropertyCamera CurrentCamera
Definition: fbrenderer.h:686
FBPickInfos(FBModel *pModel, FBVector3d pPoint, FBVector3d pNormal, int pSubItemIndex)
FBPickInfos.
Definition: fbrenderer.h:283
FBPropertyScene Scene
Read Write Property: Scene that the renderer will use/draw
Definition: fbrenderer.h:694
Display in crossed free view stereo mode.
Definition: fbrenderer.h:103
FBDisplayWhat
Model display mask This mask determines what types of models are displayed by the renderer...
Definition: fbrenderer.h:111
class FBPropertyBaseComponent< FBScene * > FBPropertyScene
Definition: fbcore.h:69
FBPropertyInt RendererUpdateId
Read Only Property: Current Render Update Id.
Definition: fbrenderer.h:709
Create new manipulators using the FBManipulator class.
Definition: Python-ast.h:18
FBPropertyInt CurrentPaneCallbackIndex
Read Write Property: Current Pane's Renderer Callback Index.
Definition: fbrenderer.h:714
PropertyList: Concrete class for PropertyList of component
Definition: fbcomponent.h:553
Cameras are displayed.
Definition: fbrenderer.h:118
FBPropertyBool SelectionOverride
Read write Property: Add transparent color override layer on selected models if true.
Definition: fbrenderer.h:704
#define __FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:68
Template class to contain an array of items.
Definition: fbarray.h:77
Display in active mode.
Definition: fbrenderer.h:97
Light class.
Definition: fblight.h:85
class FBVector3< double > FBVector3d
3D vector.
Definition: fbtypes.h:438
Display in Horizontal Interlace stereo mode.
Definition: fbrenderer.h:98
#define FBSDKNamespace
FBSDKNamespace define.
Definition: fbversion.h:64
FBPropertyBool DefaultCameraFrontPlateRendering
Read write Property: Set true to use default camera front plate rendering; set false to disable it...
Definition: fbrenderer.h:371
FBPropertyManipulatorTransform ManipulatorTransform
Read Only Property: Manipulator responsible of moving objects
Definition: fbrenderer.h:690
Picking information structure.
Definition: fbrenderer.h:275
Basic class definitions.
FBStereoDisplayMode
Definition: fbrenderer.h:92
FBPropertyBool AutoEvaluate
Read Write Property: Indicate if a call to RenderBegin will also cause a re-evaluation of the scene...
Definition: fbrenderer.h:695
FBPropertyInt DisplaySetUpdateId
Read Only Property: Current DisplaySet Update Id.
Definition: fbrenderer.h:708
FBPropertyBool IDBufferPicking
Read write Property: Use ID (Color) Buffer for picking, instead of OpenGl selection buffer picking...
Definition: fbrenderer.h:701
3D icons are displayed (3D icons are 3D elements that do not exist in the scene). ...
Definition: fbrenderer.h:119
class FBArrayTemplate< FBPickInfos > FBPickInfosList
typedef class FBSDK_DLL FBArrayTemplate FBPickInfosList
Definition: fbrenderer.h:295
FBDeviceKeyboardKey
Keyboard keys (for input).
Definition: fbrenderer.h:134
#define K_DEPRECATED_2014
Definition: kaydara.h:412
Display in Luminance Analygh stereo mode.
Definition: fbrenderer.h:101
#define FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:62
FBPropertyBool IDBufferDisplay
Read write Property: Render Model's unique Color ID into color Buffer (used for picking) ...
Definition: fbrenderer.h:703
End of enum, this valued indicates the number of picking modes available.
Definition: fbrenderer.h:129
Display in Checkboard Interlace stereo mode.
Definition: fbrenderer.h:99
FBPropertyBool FrustumCulling
Read Write Property: Turn on/off the early frustum culling optimization.
Definition: fbrenderer.h:699
FBPropertyBool DefaultLightVolumeRendering
Read write Property: Set true to use default light volume rendering; set false to disable it...
Definition: fbrenderer.h:374
bool operator==(const FBPickInfos &pLhs, const FBPickInfos &pRhs)
Null models are displayed.
Definition: fbrenderer.h:113
FBPropertyDouble IDBufferPickingAlpha
Read write Property: Those Semi-transparent (Alpha Blend) geometry(region) contribute less than this ...
Definition: fbrenderer.h:702
FBPropertyBool DisplayNormals
Read Write Property: Display model normals in main viewer.
Definition: fbrenderer.h:700
FBPickInfosList * FBCreatePickInfosList()
Create a FBPickInfosList object.
FBVector3d mPoint
Location of the pick on the model's surface in world space.
Definition: fbrenderer.h:287
FBModelShadingMode
Modes for model shading.
Definition: fbmodel.h:181
End of enum, this value indicates the number of display modes available.
Definition: fbrenderer.h:82
class FBPropertyBase< int, kFBPT_int > FBPropertyInt
Property: int
Standard picking mode.
Definition: fbrenderer.h:126
class FBPropertyBase< FBColor, kFBPT_ColorRGB > FBPropertyColor
FBPropertyColor type definition.
Declaration for the classes FBShaderManager, FBShader, FBPropertyListShader and other subclasses...
Display in Analygh stereo mode.
Definition: fbrenderer.h:100
FBArrangeMode
Modes for arranging objects in schematic view.
Definition: fbrenderer.h:87
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Definition: fbrenderer.h:48
FBPropertyBool AdvancedMaterialMode
Read write Property: Turn on/off advanced material setting UI widgets.
Definition: fbrenderer.h:720
void FBDestroyPickInfosList(FBPickInfosList *pPickInfosList)
Delete a FBPickInfosList object.
FBPropertyInt CurrentPaneCallbackPrefIndex
Read Write Property: Current Pane's Renderer Callback Preference Index.
Definition: fbrenderer.h:715
update this count value when add new mode
Definition: fbrenderer.h:104
Arrange all objects vertically.
Definition: fbrenderer.h:89
FBPropertyDouble SelectionOverrideTransparency
Read write Property: Selection override layer transparency.
Definition: fbrenderer.h:705
X-Ray picking mode (obstructed models are displayed in overlay).
Definition: fbrenderer.h:127
FBPropertyColor SelectionOverrideColor
Read write Property: Selection override layer color.
Definition: fbrenderer.h:706
FBPickingMode
3D picking mode.
Definition: fbrenderer.h:125
FBPropertyInt RegisteredCallbackCount
Read Only Property: Registered Renderer Callback Count.
Definition: fbrenderer.h:713
FBPropertyBool EvaluateMode
Read Write Property: When true (default), call to Render will perform evaluation. ...
Definition: fbrenderer.h:696