00001 #ifndef __FBRENDERER_H__
00002 #define __FBRENDERER_H__
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00043 #include <kaydaradef.h>
00044 #ifndef FBSDK_DLL
00045
00048 #define FBSDK_DLL K_DLLIMPORT
00049 #endif
00050
00051 #if !defined(K_NO_MANIPULATOR)
00052 #include <fbsdk/fbmanipulator.h>
00053 #endif
00054
00055 #include <fbsdk/fbcomponent.h>
00056 #include <fbsdk/fbmodel.h>
00057 #include <fbsdk/fbcamera.h>
00058 #include <fbsdk/fblight.h>
00059 #include <fbsdk/fbshader.h>
00060 #include <fbcontrols/fbcontrols.h>
00061
00062 #ifdef FBSDKUseNamespace
00063 namespace FBSDKNamespace {
00064 #endif
00065
00066 __FB_FORWARD( FBRenderer );
00067 __FB_FORWARD( FBRendererCallback );
00068
00069 FB_FORWARD( FBView );
00070
00071 FB_DEFINE_COMPONENT( FBSDK_DLL, Renderer );
00072
00073 FB_FORWARD( FBViewingOptions );
00074
00076 enum FBDisplayMode {
00077 kFBDisplayModeDefault = 0,
00078 kFBDisplayModeTexture,
00079 kFBDisplayModeHardShade,
00080 kFBDisplayModeFlatShade,
00081 kFBDisplayModeWireFrame,
00082 kFBDisplayModeCount
00083 };
00084
00085 enum FBStereoDisplayMode
00086 {
00087 kFBStereoDisplayCenterEye = 0,
00088 kFBStereoDisplayLeftEye,
00089 kFBStereoDisplayRightEye,
00090 kFBStereoDisplayActive,
00091 kFBStereoDisplayHorizontalInterlace,
00092 kFBStereoDisplayCheckerboard,
00093 kFBStereoDisplayAnaglyph,
00094 kFBStereoDisplayAnaglyphLuminance,
00095 kFBStereoDisplayFreeviewParallel,
00096 kFBStereoDisplayFreeviewCrossed,
00097 kFBStereoDisplayModeCount = 10
00098 };
00099
00101
00104 enum FBDisplayWhat {
00105 kFBDisplayNone = 0,
00106 kFBDisplayNull = (1 << 0),
00107 kFBDisplayMarker = (1 << 1),
00108 kFBDisplaySkeleton = (1 << 2),
00109 kFBDisplayCenter = (1 << 3),
00110 kFBDisplayLight = (1 << 4),
00111 kFBDisplayCamera = (1 << 5),
00112 kFBDisplay3dIcon = (1 << 6),
00113 kFBDisplayAll = 0xff
00114 };
00115
00117
00118 enum FBPickingMode {
00119 kFBPickingModeStandard = 0,
00120 kFBPickingModeXRay,
00121 kFBPickingModeModelsOnly,
00122 kFBPickingModeCount
00123 };
00124
00126
00127 enum FBDeviceKeyboardKey {
00128 kFBDKeyPageUp,
00129 kFBDKeyPageDown,
00130 kFBDKeyEnd,
00131 kFBDKeyHome,
00132 kFBDKeyArrowLeft,
00133 kFBDKeyArrowUp,
00134 kFBDKeyArrowRight,
00135 kFBDKeyArrowDown,
00136 kFBDKeyReturn,
00137 kFBDKeyEscape,
00138 kFBDKeySpace,
00139 kFBDKey1,
00140 kFBDKey2,
00141 kFBDKey3,
00142 kFBDKey4,
00143 kFBDKey5,
00144 kFBDKey6,
00145 kFBDKey7,
00146 kFBDKey8,
00147 kFBDKey9,
00148 kFBDKey0,
00149 kFBDKeyF1,
00150 kFBDKeyF2,
00151 kFBDKeyF3,
00152 kFBDKeyF4,
00153 kFBDKeyF5,
00154 kFBDKeyF6,
00155 kFBDKeyF7,
00156 kFBDKeyF8,
00157 kFBDKeyF9,
00158 kFBDKeyF10,
00159 kFBDKeyF11,
00160 kFBDKeyF12
00161 };
00162
00163 FB_DEFINE_ENUM( FBSDK_DLL, DeviceKeyboardKey );
00164
00168 class FBSDK_DLL FBViewingOptions
00169 {
00170 public:
00173 FBCamera* GetViewingCamera();
00174
00178 FBModelShadingMode& ShadingMode();
00179
00183 FBStereoDisplayMode& StereoDisplayMode();
00184
00188 int& DisplayWhat();
00189
00193 FBPickingMode& PickingMode();
00194
00197 bool& ShowTimeCode();
00198
00201 bool& ShowSafeArea();
00202
00205 bool& ShowCameraLabel();
00206
00210 K_DEPRECATED_2014 bool InPicking() const;
00211
00214 bool IsInSelectionBufferPicking() const;
00215
00218 bool IsInColorBufferPicking() const;
00219
00222 unsigned int RenderCallbackPrefIndex() const;
00223
00224 private:
00225 FBViewingOptions();
00226 FBViewingOptions(const FBViewingOptions &);
00227 FBViewingOptions & operator =(const FBViewingOptions &);
00228 };
00229
00230
00232
00234
00263 struct FBPickInfos
00264 {
00271 FBPickInfos( FBModel* pModel, FBVector3d pPoint, FBVector3d pNormal, int pSubItemIndex )
00272 : mModel( pModel ), mPoint( pPoint ), mNormal (pNormal), mSubItemIndex(pSubItemIndex) {};
00273
00274 FBModel* mModel;
00275 FBVector3d mPoint;
00276 FBVector3d mNormal;
00277 int mSubItemIndex;
00278 };
00279
00280 bool operator==( const FBPickInfos& pLhs, const FBPickInfos& pRhs );
00281
00283 typedef class FBSDK_DLL FBArrayTemplate<FBPickInfos> FBPickInfosList;
00284
00291 FBSDK_DLL FBPickInfosList* FBCreatePickInfosList();
00292
00296 FBSDK_DLL void FBDestroyPickInfosList( FBPickInfosList* pPickInfosList );
00297
00299
00301
00303 class FBSDK_DLL FBRendererCallback : public FBComponent
00304 {
00305
00306 __FBClassDeclare( FBRendererCallback,FBComponent );
00307 public:
00308
00311 FBRendererCallback(const char* pName);
00312
00316 virtual const char* GetCallbackName() const = 0;
00317
00322 virtual const char* GetCallbackDesc() const = 0;
00323
00329 virtual unsigned int GetCallbackPrefCount() const;
00330
00334 virtual const char* GetCallbackPrefName(unsigned int pIndex) const;
00335
00339 virtual void Render(FBRenderOptions* pRenderOptions);
00340
00344 virtual void Attach();
00345
00349 virtual void Detach();
00350
00356 virtual void DetachDisplayContext(FBViewingOptions* pViewOption);
00357
00358 FBPropertyBool SupportIDBufferPicking;
00359 FBPropertyBool DefaultCameraFrontPlateRendering;
00360 FBPropertyBool DefaultCameraBackPlateRendering;
00361 FBPropertyBool DefaultLightGroundProjectionRendering;
00362 FBPropertyBool DefaultLightVolumeRendering;
00363 };
00364
00365 FB_DEFINE_COMPONENT ( FBSDK_DLL, RendererCallback );
00366
00374 #define FBRegisterRendererCallback( UniqueNameStr, ClassName, Label, Description, IconFilename ) \
00375 HIObject CreateRendererCallback##ClassName( HIObject ,const char* pName,void * ) \
00376 { \
00377 ClassName *Class = new ClassName( pName ); \
00378 if (Class->FBCreate()) { \
00379 return Class->GetHIObject(); \
00380 } else { \
00381 delete Class; \
00382 return NULL; \
00383 } \
00384 } \
00385 FBLibraryModule( ClassName ) \
00386 { \
00387 FBRegisterObject( ClassName##R1,"renderer/callback/ogl",Label,Description,CreateRendererCallback##ClassName,true, IconFilename ); \
00388 }
00389
00394 #define FBRendererCallbackDeclare( ClassName, Parent ) \
00395 FBClassDeclare( ClassName,Parent); \
00396 public: \
00397 ClassName(const char* pName):Parent(pName) { FBClassInit; } \
00398 private:
00399
00403 #define FBRendererCallbackImplementation( ThisComponent ) \
00404 FBClassImplementation( ThisComponent )
00405
00406
00408
00411
00412 class FBSDK_DLL FBPropertyListRendererCallback : public FBPropertyListComponent
00413 {
00414 public:
00415 FBPropertyListRendererCallback();
00422 virtual int Add( FBRendererCallback* pItem );
00427 FBRendererCallback* operator[](int pIndex);
00428
00429 private:
00430 inline virtual int Add ( FBComponent* pItem ) { return Add((FBRendererCallback*)pItem); }
00431 };
00432
00434
00436
00438 class FBSDK_DLL FBRenderer : public FBComponent
00439 {
00440
00441 __FBClassDeclare( FBRenderer,FBComponent );
00442 public:
00448 FBRenderer(HIObject pObject);
00449
00450
00458 void SetViewport(int pX,int pY,int pW,int pH);
00459
00469 bool RenderBegin(int pX,int pY,int pW,int pH);
00470
00476 bool RenderEnd(FBView* pView=NULL);
00477
00490 bool PreRender(int pLayer = -1);
00491
00496 bool Render(int pLayer = -1);
00497
00501 void OGLSetupSceneLights(FBRenderOptions& pRenderOptions);
00502
00508 void OGLModelDisplay(FBRenderOptions& pRenderOptions, FBModel& pModel);
00509
00513 bool SetViewingOptions(FBViewingOptions & pOptions);
00514
00518 FBViewingOptions * GetViewingOptions();
00519
00524 bool FrameCurrentCameraWithModels(bool pAll);
00525
00526
00536 bool MouseInput(int pX,int pY,FBInputType pInputType,int pButtonKey,FBInputModifier pModifier,int pLayer = -1);
00537
00548 bool MouseInputNormalized(float pX,float pY,FBInputType pInputType,int pButtonKey,FBInputModifier pModifier,int pLayer = -1, int pPaneId = -1);
00549
00557 bool Pick(int pX, int pY, FBPickInfosList& pPickInfosList, bool pNeedIntersectPosition = false );
00558
00567 bool PickNormalized(float pX, float pY, FBPickInfosList& pPickInfosList, bool pNeedIntersectPosition = false, int pPaneId = -1);
00568
00576 bool RectPick(int pX1, int pY1, int pX2, int pY2, FBPickInfosList& pPickInfosList);
00577
00586 bool RectPickNormalized(float pX1, float pY1, float pX2, float pY2, FBPickInfosList& pPickInfosList, int pPaneId = -1);
00587
00592 int GetLastPickInfoList(FBPickInfosList& pPickInfosList);
00593
00599 void KeyboardInput(FBDeviceKeyboardKey pKeyIndex, bool pKeyState, bool pIsTrigger = false);
00600
00606 FBModel* GetDisplayableGeometry(int pIndex );
00607
00613 FBLight* GetDisplayableLight(int pIndex );
00614
00624 const FBModelList& GetDisplayableGeometryInCameraFrustum(FBModelList* pModelList = NULL, FBCamera* pCamera = NULL);
00625
00634 bool IsModelInsideCameraFrustum(FBModel* pGeometry, FBCamera* pCamera = NULL);
00635
00636
00637 FBPropertyCamera CurrentCamera;
00638 FBPropertyBool UseCameraSwitcher;
00639
00640 #if !defined(K_NO_MANIPULATOR)
00641 FBPropertyManipulatorTransform ManipulatorTransform;
00642 FBPropertyListManipulator Manipulators;
00643 #endif
00644
00645 FBPropertyScene Scene;
00646 FBPropertyBool AutoEvaluate;
00647 FBPropertyBool Background;
00648 FBPropertyBool ShowStats;
00649 FBPropertyBool FrustumCulling;
00650 FBPropertyBool DisplayNormals;
00651 FBPropertyBool IDBufferPicking;
00652 FBPropertyDouble IDBufferPickingAlpha;
00653 FBPropertyBool IDBufferDisplay;
00654 FBPropertyBool SelectionOverride;
00655 FBPropertyDouble SelectionOverrideTransparency;
00656 FBPropertyColor SelectionOverrideColor;
00657 FBPropertyBool SelectionForceSnapPointsDisplay;
00658 FBPropertyInt DisplaySetUpdateId;
00659 FBPropertyInt RendererUpdateId;
00660 FBPropertyInt DisplayableGeometryCount;
00661 FBPropertyInt DisplayableLightCount;
00662 FBPropertyListRendererCallback RendererCallbacks;
00663 FBPropertyInt RegisteredCallbackCount;
00664 FBPropertyInt CurrentPaneCallbackIndex;
00665 FBPropertyInt CurrentPaneCallbackPrefIndex;
00666
00670 FBPropertyBool AdvancedMaterialMode;
00671
00683 FBPropertyBool AdvancedLightingMode;
00684
00685 };
00686
00687 #ifdef FBSDKUseNamespace
00688 }
00689 #endif
00690 #endif