forked from PixarAnimationStudios/OpenUSD
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.h
501 lines (450 loc) · 20.6 KB
/
camera.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
//
// Copyright 2016 Pixar
//
// Licensed under the Apache License, Version 2.0 (the "Apache License")
// with the following modification; you may not use this file except in
// compliance with the Apache License and the following modification to it:
// Section 6. Trademarks. is deleted and replaced with:
//
// 6. Trademarks. This License does not grant permission to use the trade
// names, trademarks, service marks, or product names of the Licensor
// and its affiliates, except as required to comply with Section 4(c) of
// the License and to reproduce the content of the NOTICE file.
//
// You may obtain a copy of the Apache License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the Apache License with the above modification is
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the Apache License for the specific
// language governing permissions and limitations under the Apache License.
//
#ifndef USDGEOM_GENERATED_CAMERA_H
#define USDGEOM_GENERATED_CAMERA_H
/// \file usdGeom/camera.h
#include "pxr/pxr.h"
#include "pxr/usd/usdGeom/api.h"
#include "pxr/usd/usdGeom/xformable.h"
#include "pxr/usd/usd/prim.h"
#include "pxr/usd/usd/stage.h"
#include "pxr/usd/usdGeom/tokens.h"
#include "pxr/base/gf/camera.h"
#include "pxr/base/vt/value.h"
#include "pxr/base/gf/vec3d.h"
#include "pxr/base/gf/vec3f.h"
#include "pxr/base/gf/matrix4d.h"
#include "pxr/base/tf/token.h"
#include "pxr/base/tf/type.h"
PXR_NAMESPACE_OPEN_SCOPE
class SdfAssetPath;
// -------------------------------------------------------------------------- //
// CAMERA //
// -------------------------------------------------------------------------- //
/// \class UsdGeomCamera
///
/// Transformable camera.
///
/// Describes optical properties of a camera via a common set of attributes
/// that provide control over the camera's frustum as well as its depth of
/// field. For stereo, the left and right camera are individual prims tagged
/// through the \ref UsdGeomCamera::GetStereoRoleAttr() "stereoRole attribute".
///
/// There is a corresponding class GfCamera, which can hold the state of a
/// camera (at a particular time). \ref UsdGeomCamera::GetCamera() and
/// \ref UsdGeomCamera::SetFromCamera() convert between a USD camera prim and
/// a GfCamera.
///
/// To obtain the camera's location in world space, call the following on a
/// UsdGeomCamera 'camera':
/// \code
/// GfMatrix4d camXform = camera.ComputeLocalToWorldTransform(time);
/// \endcode
/// \note
/// <b>Cameras in USD are always "Y up", regardless of the stage's orientation
/// (i.e. UsdGeomGetStageUpAxis()).</b> This means that the inverse of
/// 'camXform' (the VIEW half of the <A HREF="http://www.glprogramming.com/red/chapter03.html#name2">MODELVIEW transform in OpenGL parlance</A>)
/// will transform the world such that the camera is at the origin, looking
/// down the -Z axis, with Y as the up axis.
///
/// \sa \ref UsdGeom_LinAlgBasics
///
///
/// For any described attribute \em Fallback \em Value or \em Allowed \em Values below
/// that are text/tokens, the actual token is published and defined in \ref UsdGeomTokens.
/// So to set an attribute to the value "rightHanded", use UsdGeomTokens->rightHanded
/// as the value.
///
class UsdGeomCamera : public UsdGeomXformable
{
public:
/// Compile time constant representing what kind of schema this class is.
///
/// \sa UsdSchemaType
static const UsdSchemaType schemaType = UsdSchemaType::ConcreteTyped;
/// Construct a UsdGeomCamera on UsdPrim \p prim .
/// Equivalent to UsdGeomCamera::Get(prim.GetStage(), prim.GetPath())
/// for a \em valid \p prim, but will not immediately throw an error for
/// an invalid \p prim
explicit UsdGeomCamera(const UsdPrim& prim=UsdPrim())
: UsdGeomXformable(prim)
{
}
/// Construct a UsdGeomCamera on the prim held by \p schemaObj .
/// Should be preferred over UsdGeomCamera(schemaObj.GetPrim()),
/// as it preserves SchemaBase state.
explicit UsdGeomCamera(const UsdSchemaBase& schemaObj)
: UsdGeomXformable(schemaObj)
{
}
/// Destructor.
USDGEOM_API
virtual ~UsdGeomCamera();
/// Return a vector of names of all pre-declared attributes for this schema
/// class and all its ancestor classes. Does not include attributes that
/// may be authored by custom/extended methods of the schemas involved.
USDGEOM_API
static const TfTokenVector &
GetSchemaAttributeNames(bool includeInherited=true);
/// Return a UsdGeomCamera holding the prim adhering to this
/// schema at \p path on \p stage. If no prim exists at \p path on
/// \p stage, or if the prim at that path does not adhere to this schema,
/// return an invalid schema object. This is shorthand for the following:
///
/// \code
/// UsdGeomCamera(stage->GetPrimAtPath(path));
/// \endcode
///
USDGEOM_API
static UsdGeomCamera
Get(const UsdStagePtr &stage, const SdfPath &path);
/// Attempt to ensure a \a UsdPrim adhering to this schema at \p path
/// is defined (according to UsdPrim::IsDefined()) on this stage.
///
/// If a prim adhering to this schema at \p path is already defined on this
/// stage, return that prim. Otherwise author an \a SdfPrimSpec with
/// \a specifier == \a SdfSpecifierDef and this schema's prim type name for
/// the prim at \p path at the current EditTarget. Author \a SdfPrimSpec s
/// with \p specifier == \a SdfSpecifierDef and empty typeName at the
/// current EditTarget for any nonexistent, or existing but not \a Defined
/// ancestors.
///
/// The given \a path must be an absolute prim path that does not contain
/// any variant selections.
///
/// If it is impossible to author any of the necessary PrimSpecs, (for
/// example, in case \a path cannot map to the current UsdEditTarget's
/// namespace) issue an error and return an invalid \a UsdPrim.
///
/// Note that this method may return a defined prim whose typeName does not
/// specify this schema class, in case a stronger typeName opinion overrides
/// the opinion at the current EditTarget.
///
USDGEOM_API
static UsdGeomCamera
Define(const UsdStagePtr &stage, const SdfPath &path);
protected:
/// Returns the type of schema this class belongs to.
///
/// \sa UsdSchemaType
USDGEOM_API
UsdSchemaType _GetSchemaType() const override;
private:
// needs to invoke _GetStaticTfType.
friend class UsdSchemaRegistry;
USDGEOM_API
static const TfType &_GetStaticTfType();
static bool _IsTypedSchema();
// override SchemaBase virtuals.
USDGEOM_API
const TfType &_GetTfType() const override;
public:
// --------------------------------------------------------------------- //
// PROJECTION
// --------------------------------------------------------------------- //
///
///
/// \n C++ Type: TfToken
/// \n Usd Type: SdfValueTypeNames->Token
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: perspective
/// \n \ref UsdGeomTokens "Allowed Values": [perspective, orthographic]
USDGEOM_API
UsdAttribute GetProjectionAttr() const;
/// See GetProjectionAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateProjectionAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// HORIZONTALAPERTURE
// --------------------------------------------------------------------- //
/// Horizontal aperture in millimeters (or, more general, tenths
/// of a world unit).
/// Defaults to the standard 35mm spherical projector aperture.
///
/// \n C++ Type: float
/// \n Usd Type: SdfValueTypeNames->Float
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: 20.9549999237
USDGEOM_API
UsdAttribute GetHorizontalApertureAttr() const;
/// See GetHorizontalApertureAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateHorizontalApertureAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// VERTICALAPERTURE
// --------------------------------------------------------------------- //
/// Vertical aperture in millimeters (or, more general, tenths of
/// a world unit).
/// Defaults to the standard 35mm spherical projector aperture.
///
/// \n C++ Type: float
/// \n Usd Type: SdfValueTypeNames->Float
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: 15.2908000946
USDGEOM_API
UsdAttribute GetVerticalApertureAttr() const;
/// See GetVerticalApertureAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateVerticalApertureAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// HORIZONTALAPERTUREOFFSET
// --------------------------------------------------------------------- //
/// Horizontal aperture offset in the same units as
/// horizontalAperture. Defaults to 0.
///
/// \n C++ Type: float
/// \n Usd Type: SdfValueTypeNames->Float
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: 0.0
USDGEOM_API
UsdAttribute GetHorizontalApertureOffsetAttr() const;
/// See GetHorizontalApertureOffsetAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateHorizontalApertureOffsetAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// VERTICALAPERTUREOFFSET
// --------------------------------------------------------------------- //
/// Vertical aperture offset in the same units as
/// verticalAperture. Defaults to 0.
///
/// \n C++ Type: float
/// \n Usd Type: SdfValueTypeNames->Float
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: 0.0
USDGEOM_API
UsdAttribute GetVerticalApertureOffsetAttr() const;
/// See GetVerticalApertureOffsetAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateVerticalApertureOffsetAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// FOCALLENGTH
// --------------------------------------------------------------------- //
/// Perspective focal length in millimeters (or, more general,
/// tenths of a world unit).
///
/// \n C++ Type: float
/// \n Usd Type: SdfValueTypeNames->Float
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: 50.0
USDGEOM_API
UsdAttribute GetFocalLengthAttr() const;
/// See GetFocalLengthAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateFocalLengthAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// CLIPPINGRANGE
// --------------------------------------------------------------------- //
/// Near and far clipping distances in centimeters (or, more
/// general, world units).
///
/// \n C++ Type: GfVec2f
/// \n Usd Type: SdfValueTypeNames->Float2
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: (1, 1000000)
USDGEOM_API
UsdAttribute GetClippingRangeAttr() const;
/// See GetClippingRangeAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateClippingRangeAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// CLIPPINGPLANES
// --------------------------------------------------------------------- //
/// Additional, arbitrarily oriented clipping planes.
/// A vector (a,b,c,d) encodes a clipping plane that cuts off
/// (x,y,z) with a * x + b * y + c * z + d * 1 < 0 where (x,y,z)
/// are the coordinates in the camera's space.
///
/// \n C++ Type: VtArray<GfVec4f>
/// \n Usd Type: SdfValueTypeNames->Float4Array
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: []
USDGEOM_API
UsdAttribute GetClippingPlanesAttr() const;
/// See GetClippingPlanesAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateClippingPlanesAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// FSTOP
// --------------------------------------------------------------------- //
/// Lens aperture. Defaults to 0.0, which turns off focusing.
///
/// \n C++ Type: float
/// \n Usd Type: SdfValueTypeNames->Float
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: 0.0
USDGEOM_API
UsdAttribute GetFStopAttr() const;
/// See GetFStopAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateFStopAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// FOCUSDISTANCE
// --------------------------------------------------------------------- //
/// Distance from the camera to the focus plane in centimeters (or
/// more general, world units).
///
/// \n C++ Type: float
/// \n Usd Type: SdfValueTypeNames->Float
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: 0.0
USDGEOM_API
UsdAttribute GetFocusDistanceAttr() const;
/// See GetFocusDistanceAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateFocusDistanceAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// STEREOROLE
// --------------------------------------------------------------------- //
/// If different from mono, the camera is intended to be the left
/// or right camera of a stereo setup.
///
/// \n C++ Type: TfToken
/// \n Usd Type: SdfValueTypeNames->Token
/// \n Variability: SdfVariabilityUniform
/// \n Fallback Value: mono
/// \n \ref UsdGeomTokens "Allowed Values": [mono, left, right]
USDGEOM_API
UsdAttribute GetStereoRoleAttr() const;
/// See GetStereoRoleAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateStereoRoleAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// SHUTTEROPEN
// --------------------------------------------------------------------- //
/// Frame relative shutter open time in UsdTimeCode units (negative
/// value indicates that the shutter opens before the current
/// frame time). Used for motion blur.
///
/// \n C++ Type: double
/// \n Usd Type: SdfValueTypeNames->Double
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: 0.0
USDGEOM_API
UsdAttribute GetShutterOpenAttr() const;
/// See GetShutterOpenAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateShutterOpenAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// --------------------------------------------------------------------- //
// SHUTTERCLOSE
// --------------------------------------------------------------------- //
/// Frame relative shutter close time, analogous comments from
/// shutter:open apply. A value greater or equal to shutter:open
/// should be authored, otherwise there is no exposure and a
/// renderer should produce a black image.
///
/// \n C++ Type: double
/// \n Usd Type: SdfValueTypeNames->Double
/// \n Variability: SdfVariabilityVarying
/// \n Fallback Value: 0.0
USDGEOM_API
UsdAttribute GetShutterCloseAttr() const;
/// See GetShutterCloseAttr(), and also
/// \ref Usd_Create_Or_Get_Property for when to use Get vs Create.
/// If specified, author \p defaultValue as the attribute's default,
/// sparsely (when it makes sense to do so) if \p writeSparsely is \c true -
/// the default for \p writeSparsely is \c false.
USDGEOM_API
UsdAttribute CreateShutterCloseAttr(VtValue const &defaultValue = VtValue(), bool writeSparsely=false) const;
public:
// ===================================================================== //
// Feel free to add custom code below this line, it will be preserved by
// the code generator.
//
// Just remember to:
// - Close the class declaration with };
// - Close the namespace with PXR_NAMESPACE_CLOSE_SCOPE
// - Close the include guard with #endif
// ===================================================================== //
// --(BEGIN CUSTOM CODE)--
/// Creates a GfCamera object from the attribute values at \p time.
///
USDGEOM_API
GfCamera GetCamera(const UsdTimeCode &time) const;
/// Write attribute values from \p camera for \p time.
///
USDGEOM_API
void SetFromCamera(const GfCamera &camera, const UsdTimeCode &time);
};
PXR_NAMESPACE_CLOSE_SCOPE
#endif