All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
usdVMP.h
1 //
2 // Copyright 2016 Pixar
3 //
4 // Licensed under the Apache License, Version 2.0 (the "Apache License")
5 // with the following modification; you may not use this file except in
6 // compliance with the Apache License and the following modification to it:
7 // Section 6. Trademarks. is deleted and replaced with:
8 //
9 // 6. Trademarks. This License does not grant permission to use the trade
10 // names, trademarks, service marks, or product names of the Licensor
11 // and its affiliates, except as required to comply with Section 4(c) of
12 // the License and to reproduce the content of the NOTICE file.
13 //
14 // You may obtain a copy of the Apache License at
15 //
16 // http://www.apache.org/licenses/LICENSE-2.0
17 //
18 // Unless required by applicable law or agreed to in writing, software
19 // distributed under the Apache License with the above modification is
20 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 // KIND, either express or implied. See the Apache License for the specific
22 // language governing permissions and limitations under the Apache License.
23 //
24 #ifndef VMP_USD_USDVMP_H
25 #define VMP_USD_USDVMP_H
26 
27 // Glew must be included before gl.h
28 #include "pxr/imaging/glf/glew.h"
29 
30 #include <iostream>
31 #include <GL/gl.h>
32 #include <GL/glu.h>
33 
34 #include <boost/shared_ptr.hpp>
35 
36 #include "pxr/pxr.h"
37 #include "pxr/base/tf/diagnostic.h"
38 #include "pxr/base/tf/hash.h"
39 #include "pxr/base/tf/stringUtils.h"
40 #include "pxr/base/tf/stopwatch.h"
41 #include "pxr/usd/usd/prim.h"
42 #include "pxr/usd/usd/stage.h"
43 #include "pxr/usdImaging/usdImagingGL/engine.h"
44 
45 #include <FnViewerModifier/plugin/FnViewerModifier.h>
46 #include <FnAttribute/FnGroupBuilder.h>
47 #include <FnAttribute/FnAttribute.h>
48 #include <FnViewerModifier/plugin/FnViewerModifierInput.h>
49 #include <FnLogging/FnLogging.h>
50 
51 #include "debugCodes.h"
52 
53 FnLogSetup("USDVMP")
54 
55 namespace FnKat = Foundry::Katana;
56 
57 
58 typedef boost::shared_ptr<PXR_NS::UsdImagingGLEngine>
59  UsdImagingGLEngineSharedPtr;
60 
61 //--------------------------------------------------------------------------------
62 // USDVMP
63 //--------------------------------------------------------------------------------
64 
65 class USDVMP : public FnKat::ViewerModifier
66 {
67 public:
68  USDVMP(FnKat::GroupAttribute args);
69 
70  virtual ~USDVMP();
71 
72  static FnKat::ViewerModifier* create(FnKat::GroupAttribute args);
73 
74  static FnKat::GroupAttribute getArgumentTemplate();
75 
76  static const char* getLocationType();
77 
78  virtual void deepSetup(FnKat::ViewerModifierInput& input);
79 
80  virtual void setup(FnKat::ViewerModifierInput& input);
81 
82  virtual void draw(FnKat::ViewerModifierInput& input);
83 
84  virtual void cleanup(FnKat::ViewerModifierInput& input);
85 
86  virtual void deepCleanup(FnKat::ViewerModifierInput& input);
87 
88  static void onFrameBegin() {}
89 
90  static void onFrameEnd() {}
91 
92  // DEPRECATED: getLocalSpaceBoundingBox is preferred
93  virtual FnKat::DoubleAttribute getWorldSpaceBoundingBox(
94  FnKat::ViewerModifierInput& input);
95 
96  static void flush();
97 
98 private:
99  void _loadSubtreeForCurrentPrim();
100 
101  PXR_NS::UsdStageRefPtr _stage;
102  UsdImagingGLEngineSharedPtr _renderer;
103  PXR_NS::UsdImagingGLRenderParams _params;
104  PXR_NS::UsdPrim _prim;
105 
106  PXR_NS::GfMatrix4d _viewMatrix;
107 
108  // XXX store the last time we SetRootTransform so that we can do a sloppy
109  // comparison. The current reliable technique for getting the model
110  // matrix is from GL state (due to our clever abuse of the katana
111  // proxy system to trigger a VMP in the proxy sub-scene.)
112  double _lastModelMatrix[16];
113 
114 };
115 
116 #endif
The UsdImagingGLEngine is the main entry point API for rendering USD scenes.
Definition: engine.h:81