RenderMan API  23.0
RixSceneGraph.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 1986-2019 Pixar. All rights reserved.
5 #
6 # The information in this file (the "Software") is provided for the exclusive
7 # use of the software licensees of Pixar ("Licensees"). Licensees have the
8 # right to incorporate the Software into other products for use by other
9 # authorized software licensees of Pixar, without fee. Except as expressly
10 # permitted herein, the Software may not be disclosed to third parties, copied
11 # or duplicated in any form, in whole or in part, without the prior written
12 # permission of Pixar.
13 #
14 # The copyright notices in the Software and this entire statement, including the
15 # above license grant, this restriction and the following disclaimer, must be
16 # included in all copies of the Software, in whole or in part, and all permitted
17 # derivative works of the Software, unless such copies or derivative works are
18 # solely in the form of machine-executable object code generated by a source
19 # language processor.
20 #
21 # PIXAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL PIXAR BE
23 # LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
25 # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
26 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. IN NO CASE WILL
27 # PIXAR'S TOTAL LIABILITY FOR ALL DAMAGES ARISING OUT OF OR IN CONNECTION WITH
28 # THE USE OR PERFORMANCE OF THIS SOFTWARE EXCEED $50.
29 #
30 # Pixar
31 # 1200 Park Ave
32 # Emeryville CA 94608
33 #
34 # ------------------------------------------------------------------------------
35 */
36 
37 /*
38  * Version 2
39  *
40  * This is a preview release and is not supported. This API will change substantially
41  * in the next release of RenderMan. Names, namespaces, methods, parameters, types,
42  * enums, and the structure of the interface are expected to change.
43  *
44  */
45 
46 #ifndef RixSceneGraph_h
47 #define RixSceneGraph_h
48 
49 #include "RiTypesHelper.h" // RtUString, RtPoint3, RtMatrix4x4, etc.
50 #include "RixInterfaces.h" // RixInterface
51 #include "RtParamList.h" // RtParamList, RtDataType, RtDetailType
52 
53 class RixSGCamera;
54 class RixSGCurves;
55 class RixSGGeometry;
56 class RixSGGroup;
57 class RixSGAnalyticLight;
58 class RixSGManager;
59 class RixSGMaterial;
60 class RixSGMesh;
61 class RixSGNuPatch;
62 class RixSGPoints;
63 class RixSGProcedural;
64 class RixSGQuadric;
65 class RixSGScene;
66 class RixSGVolume;
67 class RixSGBlobby;
68 struct RixSGDisplayChannel;
69 struct RixSGShader;
70 
72 typedef uint64_t (*RixSGUpdateIdCallback)(void* ctx, RixSGGroup const* node, RtUString const& path);
73 
75 class Ri;
76 namespace Sg
77 {
78 class DagProperties;
79 }
80 namespace riley
81 {
82 class Riley;
83 }
85 
88 enum class RixSGError
89 {
90  k_Success,
93 };
94 
97 enum class RixSGDagType
98 {
99  k_Group,
100  k_Camera,
103  k_Geometry,
104  k_Quadric,
105  k_Mesh,
106  k_NuPatch,
107  k_Curves,
108  k_Points,
109  k_Blobby,
110  k_Volume,
111  k_Procedural,
112 };
113 
116 enum class RixSGShaderType
117 {
118  k_Invalid,
119  k_Pattern,
120  k_Bxdf,
121  k_Integrator,
122  k_Light,
123  k_LightFilter,
124  k_Projection,
128  k_Display,
129 };
130 
136 {
139 
142 
144  RixSGDisplayChannel(RixSGDisplayChannel const&) = default;
145 
147  RixSGDisplayChannel& operator=(RixSGDisplayChannel const&) = default;
148 
151 
154 
157 };
158 
163 {
165  RixSGShader();
166 
169 
171  RixSGShader(RixSGShader const&) = default;
172 
174  RixSGShader& operator=(RixSGShader const&) = default;
175 
178 
181 
184 
187 };
188 
194 {
195 public:
203  virtual RtUString GetIdentifier() const = 0;
204 
213  virtual RixSGError SetIdentifier(RtUString identifier) = 0;
214 
224  virtual RixSGError SetBxdf(unsigned num, RixSGShader const* nodes) = 0;
225 
236  virtual RixSGError SetLight(unsigned num, RixSGShader const* nodes) = 0;
237 
248  virtual RixSGError SetLightFilter(unsigned num, RixSGShader const* nodes) = 0;
249 
259  virtual RixSGError SetDisplace(unsigned num, RixSGShader const* nodes) = 0;
260 
261  inline RixSGMaterial() = default;
262  virtual ~RixSGMaterial() = default;
263 };
264 
271 {
272 public:
279  virtual RixSGDagType GetDagType() const = 0;
280 
288  virtual RtUString GetIdentifier() const = 0;
289 
298  virtual RixSGError SetIdentifier(RtUString identifier) = 0;
299 
312  virtual RixSGError SetTransform(unsigned numsamples, RtMatrix4x4 const* xforms,
313  float const* times) = 0;
314 
324  virtual RixSGError SetTransformNumSamples(unsigned numsamples) = 0;
325 
337  virtual RixSGError SetTransformSample(unsigned sample, RtMatrix4x4 const& xform,
338  float time) = 0;
339 
349  RixSGError SetTransform(RtMatrix4x4 const& xform);
350 
358  RixSGError SetIdentity();
359 
368  virtual RixSGError SetHidden(int state) = 0;
369 
377  virtual int GetHidden() const = 0;
378 
391  virtual RixSGError AddCoordinateSystem(RixSGGroup* coordsys) = 0;
392 
405  virtual RixSGError RemoveCoordinateSystem(RixSGGroup* coordsys) = 0;
406 
418  virtual unsigned GetNumCoordinateSystems() const = 0;
419 
432  virtual RixSGGroup* GetCoordinateSystem(unsigned idx) const = 0;
433 
451  virtual RixSGError AddChild(RixSGGroup* child) = 0;
452 
469  virtual RixSGError RemoveChild(RixSGGroup* child) = 0;
470 
487  virtual unsigned GetNumChildren() const = 0;
488 
506  virtual RixSGGroup* GetChild(unsigned idx) const = 0;
507 
524  virtual unsigned GetNumParents() const = 0;
525 
543  virtual RixSGGroup* GetParent(unsigned idx) const = 0;
544 
554  virtual RixSGGroup* FindDagNode(char const* path) const = 0;
555 
564  virtual RixSGMaterial* GetMaterial() const = 0;
565 
575  virtual RixSGError SetMaterial(RixSGMaterial* material) = 0;
576 
590  virtual RixSGError OverrideMaterial(RixSGMaterial* material, unsigned depth,
591  RixSGGroup** path) = 0;
592 
603  virtual RtParamList const& GetAttributes() const = 0;
604 
616  virtual RixSGError SetAttributes(RtParamList const& attributes) = 0;
617 
626  virtual RixSGError SetNested(bool state) = 0;
627 
635  virtual bool GetNested() const = 0;
636 
645  virtual RixSGError SetInheritTransform(bool value) = 0;
646 
648  virtual int Dirty() const = 0;
649  virtual void ToRi(Ri* ri, Sg::DagProperties const& prop) = 0;
650  virtual void ToRiley(riley::Riley* riley, Sg::DagProperties const& prop) = 0;
651  virtual void DeleteInstance(Sg::DagProperties const& prop) = 0;
652  virtual void DeleteMaster() = 0;
653  RixSGGroup(RixSGGroup const&) = delete;
654  RixSGGroup const& operator=(RixSGGroup const&) = delete;
656 
657  inline RixSGGroup() = default;
658  virtual ~RixSGGroup() = default;
659 };
660 
663 class RixSGCamera : public RixSGGroup
664 {
665 public:
674  virtual RixSGError SetRenderable(int renderable) = 0;
675 
684  virtual RixSGError SetProjection(unsigned num, RixSGShader const* nodes) = 0;
685 
695  virtual RixSGError SetDisplay(unsigned num, RixSGShader const* nodes) = 0;
696 
705  virtual RixSGError SetOrientTransform(RtMatrix4x4 const& localxform) = 0;
706 
714  virtual RtParamList const& GetProperties() const = 0;
715 
724  virtual RixSGError SetProperties(RtParamList const& prop) = 0;
725 
726 protected:
727  inline RixSGCamera() = default;
728  virtual ~RixSGCamera() = default;
729 };
730 
734 {
735 public:
743  virtual RixSGError SetActive(bool active) = 0;
744 
753  virtual RixSGError SetOrientTransform(RtMatrix4x4 const& localxform) = 0;
754 
755 protected:
756  inline RixSGClippingPlane() = default;
757  virtual ~RixSGClippingPlane() = default;
758 };
759 
763 {
764 public:
775  virtual RixSGError SetLight(unsigned num, RixSGShader const* nodes) = 0;
776 
786  virtual RixSGError SetLightFilter(unsigned num, RixSGShader const* nodes) = 0;
787 
796  virtual RixSGError SetOrientTransform(RtMatrix4x4 const& localxform) = 0;
797 
798 protected:
799  inline RixSGAnalyticLight() = default;
800  virtual ~RixSGAnalyticLight() = default;
801 };
802 
804 class RixSGGeometry : public RixSGGroup
805 {
806 public:
808  virtual RtUString Geometry() const = 0;
809 
824  virtual RixSGError SetGeometry(RtUString type) = 0;
825 
838  virtual RtParamList const& GetPrimVars() const = 0;
839 
853  virtual RixSGError SetPrimVars(RtParamList const& primvars) = 0;
854 
855 protected:
856  inline RixSGGeometry() = default;
857  virtual ~RixSGGeometry() = default;
858 };
859 
863 {
864 public:
882  virtual RixSGError SetGeometry(RtUString type) = 0;
883 
884 protected:
885  inline RixSGQuadric() = default;
886  virtual ~RixSGQuadric() = default;
887 };
888 
891 class RixSGMesh : public RixSGGeometry
892 {
893 public:
913  virtual RixSGError Define(int32_t npolys, int32_t npoints, int32_t nverts) = 0;
914 
921  virtual RixSGError SetScheme(RtUString scheme) = 0;
922 
923 protected:
924  inline RixSGMesh() = default;
925  virtual ~RixSGMesh() = default;
926 };
927 
931 {
932 public:
947  virtual RixSGError Define(int32_t npoints) = 0;
948 
949 protected:
950  inline RixSGPoints() = default;
951  virtual ~RixSGPoints() = default;
952 };
953 
956 {
957 public:
976  virtual RixSGError Define(int32_t nx, int32_t ny, int32_t nz) = 0;
977 
978 protected:
979  inline RixSGVolume() = default;
980  virtual ~RixSGVolume() = default;
981 };
982 
986 {
987 public:
1006  virtual RixSGError Define(int32_t nleaf) = 0;
1007 
1008 protected:
1009  inline RixSGBlobby() = default;
1010  virtual ~RixSGBlobby() = default;
1011 };
1012 
1016 {
1017 public:
1069  virtual RixSGError Define(RtUString type, RtUString wrap, RtUString basis, int32_t ncurves,
1070  int32_t npoints) = 0;
1071 
1072 protected:
1073  inline RixSGCurves() = default;
1074  virtual ~RixSGCurves() = default;
1075 };
1076 
1079 {
1080 public:
1118  virtual RixSGError Define(int32_t nu, int32_t uorder, int32_t nv, int32_t vorder) = 0;
1119 
1120 protected:
1121  inline RixSGNuPatch() = default;
1122  virtual ~RixSGNuPatch() = default;
1123 };
1124 
1128 {
1129 public:
1144  virtual RixSGError Define(RtUString subdivfunction, RtUString boundfunction) = 0;
1145 
1146 protected:
1147  inline RixSGProcedural() = default;
1148  virtual ~RixSGProcedural() = default;
1149 };
1150 
1154 {
1155 public:
1162  virtual RixSGMaterial* CreateMaterial(RtUString identifier) = 0;
1163 
1170  virtual RixSGError DeleteMaterial(RixSGMaterial* material) = 0;
1171 
1178  virtual RixSGGroup* CreateGroup(RtUString identifier) = 0;
1179 
1186  virtual RixSGCamera* CreateCamera(RtUString identifier) = 0;
1187 
1194  virtual RixSGClippingPlane* CreateClippingPlane(RtUString identifier) = 0;
1195 
1202  virtual RixSGAnalyticLight* CreateAnalyticLight(RtUString identifier) = 0;
1203 
1210  virtual RixSGGeometry* CreateGeometry(RtUString identifier) = 0;
1211 
1218  virtual RixSGQuadric* CreateQuadric(RtUString identifier) = 0;
1219 
1226  virtual RixSGMesh* CreateMesh(RtUString identifier) = 0;
1227 
1234  virtual RixSGPoints* CreatePoints(RtUString identifier) = 0;
1235 
1242  virtual RixSGVolume* CreateVolume(RtUString identifier) = 0;
1243 
1250  virtual RixSGBlobby* CreateBlobby(RtUString identifier) = 0;
1251 
1258  virtual RixSGCurves* CreateCurves(RtUString identifier) = 0;
1259 
1266  virtual RixSGNuPatch* CreateNuPatch(RtUString identifier) = 0;
1267 
1274  virtual RixSGProcedural* CreateProcedural(RtUString identifier) = 0;
1275 
1284  virtual RixSGError DeleteDagNode(RixSGGroup* node) = 0;
1285 
1294  virtual RixSGGroup* FindDagNode(char const* path) const = 0;
1295 
1307 
1312  virtual RixSGError Render(char const* cmd) = 0;
1317 
1324  virtual RixSGError Stop() = 0;
1325 
1332  struct ScopedEdit
1333  {
1334  ScopedEdit(RixSGScene* scene);
1335  ~ScopedEdit();
1336  RixSGScene* const sg;
1337  };
1338 
1345  virtual void EditBegin() = 0;
1346 
1353  virtual void EditEnd() = 0;
1354 
1363  virtual RixSGError Clear() = 0;
1364 
1374  virtual RixSGGroup* Root() const = 0;
1375 
1385  virtual RixSGError SetIntegrator(unsigned num, RixSGShader const* nodes) = 0;
1386 
1397  virtual RixSGError SetSampleFilter(unsigned num, RixSGShader const* nodes) = 0;
1398 
1408  virtual RixSGError SetDisplayFilter(unsigned num, RixSGShader const* nodes) = 0;
1409 
1418  virtual RixSGError SetDisplayChannel(unsigned num, RixSGDisplayChannel const* nodes) = 0;
1419 
1428  virtual RtParamList const& GetOptions() const = 0;
1429 
1439  virtual RixSGError SetOptions(RtParamList const& options) = 0;
1440 
1449  virtual RixSGError SetUpdateIdCallback(RixSGUpdateIdCallback callback, void* ctx) = 0;
1450 
1451 protected:
1452  RixSGScene() = default;
1453  virtual ~RixSGScene() = default;
1454 };
1455 
1458 {
1459 public:
1465  virtual RixSGScene* CreateScene(RtUString orientation = US_NULL, char sep = '|') = 0;
1466 
1471  virtual RixSGError DeleteScene(RixSGScene* scene) = 0;
1472 
1473 protected:
1475  {}
1476  virtual ~RixSGManager() = default;
1477 };
1478 
1479 /* inlined */
1480 
1482 {}
1483 
1485 {}
1486 
1488 {}
1489 
1491  : type(t), name(n), handle(h)
1492 {}
1493 
1495 {
1496  return SetTransform(1, &xform, nullptr);
1497 }
1498 
1500 {
1501  return SetTransformNumSamples(0);
1502 }
1503 
1505 {
1506  sg->EditBegin();
1507 }
1508 
1510 {
1511  sg->EditEnd();
1512 }
1513 
1514 #endif // RixSceneGraph_h
Special geometry DAG node.
Operation not permitted in current state.
RixSGError
Definition: RixSceneGraph.h:88
RixSGScene *const sg
#define US_NULL
Custom proceudral geometry.
Quadric geometry, e.g. spheres.
Light emission filter.
virtual void EditEnd()=0
Volume geometry.
Output display driver.
Surface, subsurface, volumetric scattering.
pxrcore::ParamList RtParamList
Definition: RtParamList.h:47
pxrcore::DataType RtDataType
Definition: RtParamList.h:44
PRMANAPI const RtUString k_float
"float"
Definition: Riley.h:56
virtual RixSGError SetTransform(unsigned numsamples, RtMatrix4x4 const *xforms, float const *times)=0
RtDataType type
Display channel type, e.g. color.
uint64_t(* RixSGUpdateIdCallback)(void *ctx, RixSGGroup const *node, RtUString const &path)
Callback type used to optionally set object ids.
Definition: RixSceneGraph.h:72
Primary sample filter.
ScopedEdit(RixSGScene *scene)
RtUString handle
Display channel name, e.g. "Ci".
Analytic and geometric light emission.
Volume geometry.
RixSGDagType
Definition: RixSceneGraph.h:97
Polygon and subdivision meshes.
Entry point for constructing and manipulating scene graphs.
Implicit surface geometry.
Textural pattern.
RixSGShaderType
Surface displacement.
Definition: ri.hpp:46
pxrcore::UString RtUString
RtParamList params
Display channel parameters.
Hair, ribbion, and curve geometry.
RtUString name
Shading node name, e.g. PxrDiffuse.
Grouping and transformations.
RixSGError SetIdentity()
pxrcore::Matrix4x4 RtMatrix4x4
Definition: RiTypesHelper.h:73
RtUString handle
User specified identifier, e.g. "diffuse1".
RixSGShaderType type
Shading node type, e.g., pattern, bxdf, etc.
RixSGDisplayChannel()
Default constructor of float type.
Operation input is invalid.
virtual void EditBegin()=0
Special geometry.
Invalid shading node.
Point particle and disk geometry.
RtParamList params
Shading node parameters.
RixSGShader()
Default constructor of invalid type.