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 
71  FB_DEFINE_COMPONENT( FBSDK_DLL, Renderer );
72 
73  FB_FORWARD( FBViewingOptions );
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 
175  class FBSDK_DLL FBViewingOptions
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 
216  bool IsInSelectionBufferPicking() const;
217 
220  bool IsInColorBufferPicking() const;
221 
224  unsigned int RenderCallbackPrefIndex() const;
225 
229  int PaneIndex() const;
230 
231  private:
232  FBViewingOptions();
233  FBViewingOptions(const FBViewingOptions &);
234  FBViewingOptions & operator =(const FBViewingOptions &);
235  };
236 
237 
239  // FBPickInfos
241 
270  struct FBPickInfos
271  {
278  FBPickInfos( FBModel* pModel, FBVector3d pPoint, FBVector3d pNormal, int pSubItemIndex )
279  : mModel( pModel ), mPoint( pPoint ), mNormal (pNormal), mSubItemIndex(pSubItemIndex) {};
280 
281  FBModel* mModel;
285  };
286 
287  bool operator==( const FBPickInfos& pLhs, const FBPickInfos& pRhs );
288 
290  typedef class FBSDK_DLL FBArrayTemplate<FBPickInfos> FBPickInfosList;
291 
298  FBSDK_DLL FBPickInfosList* FBCreatePickInfosList();
299 
303  FBSDK_DLL void FBDestroyPickInfosList( FBPickInfosList* pPickInfosList );
304 
306  // FBRendererCallback
308 
310  class FBSDK_DLL FBRendererCallback : public FBComponent
311  {
312  //--- Open Reality declaration.
313  __FBClassDeclare( FBRendererCallback,FBComponent );
314  public:
315 
318  FBRendererCallback(const char* pName);
319 
323  virtual const char* GetCallbackName() const = 0;
324 
329  virtual const char* GetCallbackDesc() const = 0;
330 
336  virtual unsigned int GetCallbackPrefCount() const;
337 
341  virtual const char* GetCallbackPrefName(unsigned int pIndex) const;
342 
346  virtual void Render(FBRenderOptions* pRenderOptions);
347 
351  virtual void Attach();
352 
356  virtual void Detach();
357 
363  virtual void DetachDisplayContext(FBViewingOptions* pViewOption);
364 
365  FBPropertyBool SupportIDBufferPicking;
366  FBPropertyBool DefaultCameraFrontPlateRendering;
367  FBPropertyBool DefaultCameraBackPlateRendering;
368  FBPropertyBool DefaultLightGroundProjectionRendering;
369  FBPropertyBool DefaultLightVolumeRendering;
370  };
371 
372  FB_DEFINE_COMPONENT ( FBSDK_DLL, RendererCallback );
373 
381 #define FBRegisterRendererCallback( UniqueNameStr, ClassName, Label, Description, IconFilename ) \
382  HIObject CreateRendererCallback##ClassName( HIObject /*pOwner*/,const char* pName,void * /*pData*/) \
383  { \
384  ClassName *Class = new ClassName( pName ); \
385  if (Class->FBCreate()) { \
386  return Class->GetHIObject(); \
387  } else { \
388  delete Class; \
389  return NULL; \
390  } \
391  } \
392  FBLibraryModule( ClassName ) \
393  { \
394  FBRegisterObject( ClassName##R1,"renderer/callback/ogl",Label,Description,CreateRendererCallback##ClassName,true, IconFilename ); \
395  }
396 
401 #define FBRendererCallbackDeclare( ClassName, Parent ) \
402  FBClassDeclare( ClassName,Parent); \
403 public: \
404  ClassName(const char* pName):Parent(pName) { FBClassInit; } \
405 private:
406 
410 #define FBRendererCallbackImplementation( ThisComponent ) \
411  FBClassImplementation( ThisComponent )
412 
413 
415  // FBPropertyListRendererCallback
418 
419  class FBSDK_DLL FBPropertyListRendererCallback : public FBPropertyListComponent
420  {
421  public:
422  FBPropertyListRendererCallback();
429  virtual int Add( FBRendererCallback* pItem );
434  FBRendererCallback* operator[](int pIndex);
435 
436  private:
437  inline virtual int Add ( FBComponent* pItem ) { return Add((FBRendererCallback*)pItem); }
438  };
439 
441  // FBRenderer
443 
445  class FBSDK_DLL FBRenderer : public FBComponent
446  {
447  //--- Open Reality declaration.
448  __FBClassDeclare( FBRenderer,FBComponent );
449  public:
455  FBRenderer(HIObject pObject);
456 
457  //--- Rendering manipulation
465  void SetViewport(int pX,int pY,int pW,int pH);
466 
476  bool RenderBegin(int pX,int pY,int pW,int pH);
477 
483  bool RenderEnd(FBView* pView=NULL);
484 
497  bool PreRender(int pLayer = -1);
498 
503  bool Render(int pLayer = -1);
504 
508  void OGLSetupSceneLights(FBRenderOptions& pRenderOptions);
509 
515  void OGLModelDisplay(FBRenderOptions& pRenderOptions, FBModel& pModel);
516 
520  bool SetViewingOptions(FBViewingOptions & pOptions);
521 
525  FBViewingOptions * GetViewingOptions();
526 
531  bool FrameCurrentCameraWithModels(bool pAll);
532 
534  void ArrangeSelectedObjectsInSchematic();
535 
540  bool ArrangeObjectsInSchematicFromModel( const FBModel& pModel );
541 
545  void ArrangeAllInSchematic(FBArrangeMode pMode);
546 
555  bool GetSchematicNodesBoundingBox( bool pConsiderCollapsedNodes, int& pTop, int& pLeft, int& pBottom, int& pRight );
556 
566  bool GetSchematicNodesBoundingBoxFromModel( FBModel* pModel, bool pConsiderCollapsedNodes, int& pTop, int& pLeft, int& pBottom, int& pRight );
567 
568  //--- \internal Camera manipulation, Manipulators
579  bool MouseInput(int pX,int pY,FBInputType pInputType,int pButtonKey,FBInputModifier pModifier,int pWheelDeltaValue=0,int pLayer = -1);
580 
592  bool MouseInputNormalized(float pX,float pY,FBInputType pInputType,int pButtonKey,FBInputModifier pModifier,int pWheelDeltaValue, int pLayer = -1, int pPaneId = -1);
593 
601  bool Pick(int pX, int pY, FBPickInfosList& pPickInfosList, bool pNeedIntersectPosition = false );
602 
611  bool PickNormalized(float pX, float pY, FBPickInfosList& pPickInfosList, bool pNeedIntersectPosition = false, int pPaneId = -1);
612 
620  bool RectPick(int pX1, int pY1, int pX2, int pY2, FBPickInfosList& pPickInfosList);
621 
630  bool RectPickNormalized(float pX1, float pY1, float pX2, float pY2, FBPickInfosList& pPickInfosList, int pPaneId = -1);
631 
636  int GetLastPickInfoList(FBPickInfosList& pPickInfosList);
637 
643  void KeyboardInput(FBDeviceKeyboardKey pKeyIndex, bool pKeyState, bool pIsTrigger = false);
644 
650  FBModel* GetDisplayableGeometry(int pIndex );
651 
657  FBLight* GetDisplayableLight(int pIndex );
658 
668  const FBModelList& GetDisplayableGeometryInCameraFrustum(FBModelList* pModelList = NULL, FBCamera* pCamera = NULL);
669 
678  bool IsModelInsideCameraFrustum(FBModel* pGeometry, FBCamera* pCamera = NULL);
679 
680  // Properties
681  FBPropertyCamera CurrentCamera;
682  FBPropertyBool UseCameraSwitcher;
683 
684 #if !defined(K_NO_MANIPULATOR)
685  FBPropertyManipulatorTransform ManipulatorTransform;
686  FBPropertyListManipulator Manipulators;
687 #endif
688 
689  FBPropertyScene Scene;
690  FBPropertyBool AutoEvaluate;
691  FBPropertyBool EvaluateMode;
692  FBPropertyBool Background;
693  FBPropertyBool ShowStats;
694  FBPropertyBool FrustumCulling;
695  FBPropertyBool DisplayNormals;
696  FBPropertyBool PickingEnabled;
697  FBPropertyBool IDBufferPicking;
698  FBPropertyDouble IDBufferPickingAlpha;
699  FBPropertyBool IDBufferDisplay;
700  FBPropertyBool SelectionOverride;
701  FBPropertyDouble SelectionOverrideTransparency;
702  FBPropertyColor SelectionOverrideColor;
703  FBPropertyBool SelectionForceSnapPointsDisplay;
704  FBPropertyInt DisplaySetUpdateId;
705  FBPropertyInt RendererUpdateId;
706  FBPropertyInt DisplayableGeometryCount;
707  FBPropertyInt DisplayableLightCount;
708  FBPropertyListRendererCallback RendererCallbacks;
709  FBPropertyInt RegisteredCallbackCount;
710  FBPropertyInt CurrentPaneCallbackIndex;
711  FBPropertyInt CurrentPaneCallbackPrefIndex;
712  FBPropertyBool HideManipulatorsOnManip;
713 
717  FBPropertyBool AdvancedMaterialMode;
718 
730  FBPropertyBool AdvancedLightingMode;
731 
736  int GetViewerTextureId();
737 
741  void CloneViewAdd(FBView* pView);
742 
746  void CloneViewRemove(FBView* pView);
747 
752  void CloneViewRender(int pWidth, int pHeight);
753 
769  void SetCameraInPane( FBCamera* pCamera, unsigned int pPaneIndex );
770 
783  FBCamera* GetCameraInPane( unsigned int pPaneIndex );
784 
788  void SetPaneCount( unsigned int pPaneCount );
789 
793  unsigned int GetPaneCount();
794 
799  bool SetSelectedPaneIndex( unsigned int pPaneIndex );
800 
804  unsigned int GetSelectedPaneIndex() const;
805 
812  void SetSchematicViewInPane( unsigned int pPaneIndex, bool pActive );
813 
817  int GetSchematicViewPaneIndex();
818 
826  void SetCameraSwitcherInPane( unsigned int pPaneIndex, bool pActive );
827 
834  bool IsCameraSwitcherInPane( unsigned int pPaneIndex );
835  };
836 
837 #ifdef FBSDKUseNamespace
838 }
839 #endif
840 #endif /* this must be the last line of this file */
Cameras are displayed.
Definition: fbrenderer.h:118
#define __FBClassDeclare(Name, Parent)
For internal use only.
Definition: fbcomponent.h:132
Model class.
Definition: fbmodel.h:273
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
FBVector3d mPoint
Location of the pick on the model's surface in world space.
Definition: fbrenderer.h:282
int mSubItemIndex
Picked sub item index, -1 for whole object.
Definition: fbrenderer.h:284
FBStereoDisplayMode
Definition: fbrenderer.h:92
#define FB_DEFINE_COMPONENT(DllTag, Type)
Define a component and give it the ability to be a property.
Definition: fbproperties.h:139
Display in active mode.
Definition: fbrenderer.h:97
FBDeviceKeyboardKey
Keyboard keys (for input).
Definition: fbrenderer.h:134
Display in Horizontal Interlace stereo mode.
Definition: fbrenderer.h:98
class FBVector3< double > FBVector3d
3D vector.
Definition: fbtypes.h:438
#define NULL
Definition: kaydara.h:179
Template class to contain an array of items.
Definition: fbarray.h:77
Null models are displayed.
Definition: fbrenderer.h:113
class FBPropertyBase< int, kFBPT_int > FBPropertyInt
Property: int
3D icons are displayed (3D icons are 3D elements that do not exist in the scene). ...
Definition: fbrenderer.h:119
class FBPropertyBase< FBColor, kFBPT_ColorRGB > FBPropertyColor
FBPropertyColor type definition.
Display in Luminance Analygh stereo mode.
Definition: fbrenderer.h:101
End of enum, this value indicates the number of display modes available.
Definition: fbrenderer.h:82
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
Standard picking mode.
Definition: fbrenderer.h:126
Base class for Cameras.
Display in Analygh stereo mode.
Definition: fbrenderer.h:100
#define FB_DEFINE_ENUM(DllTag, Type)
Define an enum and give it the ability to be a property.
Definition: fbproperties.h:148
Contains the user interface components for the SDK.
FBPickInfos(FBModel *pModel, FBVector3d pPoint, FBVector3d pNormal, int pSubItemIndex)
FBPickInfos.
Definition: fbrenderer.h:278
update this count value when add new mode
Definition: fbrenderer.h:104
FBPickingMode
3D picking mode.
Definition: fbrenderer.h:125
Arrange all objects vertically.
Definition: fbrenderer.h:89
FBModelShadingMode
Modes for model shading.
Definition: fbmodel.h:181
FBArrangeMode
Modes for arranging objects in schematic view.
Definition: fbrenderer.h:87
Wire-frame rendering.
Definition: fbrenderer.h:81
Create new manipulators using the FBManipulator class.
X-Ray picking mode (obstructed models are displayed in overlay).
Definition: fbrenderer.h:127
Definition: Python-ast.h:18
Lights are displayed.
Definition: fbrenderer.h:117
#define __FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:68
Nothing is displayed.
Definition: fbrenderer.h:112
class FBArrayTemplate< FBModel * > FBModelList
typedef class FBSDK_DLL FBArrayTemplate FBModelList;
Definition: fbcharacter.h:597
Textures are displayed.
Definition: fbrenderer.h:78
#define FBSDKNamespace
FBSDKNamespace define.
Definition: fbversion.h:64
Display in Center Eye Camera, No Stereo effect.
Definition: fbrenderer.h:94
Basic class definitions.
FBInputType
Types of input events.
Definition: fbcontrols.h:123
Arrange all objects horizontally.
Definition: fbrenderer.h:88
Use default display mode.
Definition: fbrenderer.h:77
class FBPropertyBaseComponent< FBCamera * > FBPropertyCamera
Definition: fbcamera.h:58
int pWidth
Definition: fbtool.h:209
Markers are displayed.
Definition: fbrenderer.h:114
MotionBuilder SDK base class.
Definition: fbcomponent.h:664
bool operator==(const FBPickInfos &pLhs, const FBPickInfos &pRhs)
Models-only mode (no nulls or skeletons are displayed).
Definition: fbrenderer.h:128
class FBPropertyBase< double, kFBPT_double > FBPropertyDouble
Property: double
#define FB_FORWARD(ClassName)
Forwarding of class and typedef declaration.
Definition: fbtypes.h:62
Everything is displayed.
Definition: fbrenderer.h:120
int int pHeight
Definition: fbtool.h:209
Picking information structure.
Definition: fbrenderer.h:270
Display in parallel free view stereo mode.
Definition: fbrenderer.h:102
Display in Right Eye Caerma, No Stereo effect.
Definition: fbrenderer.h:96
Display in Left Eye Caerma, No Stereo effect.
Definition: fbrenderer.h:95
FBInputModifier
Input Modifiers (Ctrl, Alt, Shift).
Definition: fbcontrols.h:141
Skeletons and bones are displayed.
Definition: fbrenderer.h:115
Centers are displayed.
Definition: fbrenderer.h:116
Declaration for the classes FBShaderManager, FBShader, FBPropertyListShader and other subclasses...
#define FBSDK_DLL
Be sure that FBSDK_DLL is defined only once...
Definition: fbrenderer.h:48
FBVector3d mNormal
Normal of the pick on the model's surface in world space.
Definition: fbrenderer.h:283
class FBPropertyBase< bool, kFBPT_bool > FBPropertyBool
Property: bool
Display in crossed free view stereo mode.
Definition: fbrenderer.h:103
FBDisplayMode
Model display options.
Definition: fbrenderer.h:76