-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup camera projection matrix, lights, materials.
Signed-off-by: furby™ <devs@wabi.foundation>
- Loading branch information
Showing
10 changed files
with
442 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* ---------------------------------------------------------------- | ||
* :: : M E T A V E R S E : :: | ||
* ---------------------------------------------------------------- | ||
* Licensed under the terms set forth in the LICENSE.txt file, this | ||
* file is available at https://openusd.org/license. | ||
* | ||
* Copyright (C) 2016 Pixar. | ||
* Copyright (C) 2024 Wabi Foundation. All Rights Reserved. | ||
* ---------------------------------------------------------------- | ||
* . x x x . o o o . x x x . : : : . o x o . : : : . | ||
* ---------------------------------------------------------------- */ | ||
|
||
import Gf | ||
|
||
/* note: the typealiases are documented the same way twice, | ||
* keep it like this so that sourcekit shows documentation | ||
* regardless of which typealias a user might use in their | ||
* code. */ | ||
|
||
/** | ||
* # GfRotation | ||
* | ||
* Basic type for a 3-space rotation specification. | ||
*/ | ||
public typealias GfRotation = Pixar.GfRotation | ||
|
||
public extension Gf | ||
{ | ||
/** | ||
* # GfRotation | ||
* | ||
* Basic type for a 3-space rotation specification. | ||
*/ | ||
typealias Rotation = GfRotation | ||
} | ||
|
||
public extension Gf.Rotation | ||
{ | ||
static func * (lhs: Gf.Rotation, rhs: Gf.Rotation) -> Gf.Rotation | ||
{ | ||
var result = lhs | ||
result *= rhs | ||
return result | ||
} | ||
|
||
static func * (rotation: Gf.Rotation, scale: Double) -> Gf.Rotation | ||
{ | ||
var result = rotation | ||
result *= scale | ||
return result | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* ---------------------------------------------------------------- | ||
* :: : M E T A V E R S E : :: | ||
* ---------------------------------------------------------------- | ||
* Licensed under the terms set forth in the LICENSE.txt file, this | ||
* file is available at https://openusd.org/license. | ||
* | ||
* Copyright (C) 2016 Pixar. | ||
* Copyright (C) 2024 Wabi Foundation. All Rights Reserved. | ||
* ---------------------------------------------------------------- | ||
* . x x x . o o o . x x x . : : : . o x o . : : : . | ||
* ---------------------------------------------------------------- */ | ||
|
||
import Hdx | ||
|
||
public enum Hdx | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* ---------------------------------------------------------------- | ||
* :: : M E T A V E R S E : :: | ||
* ---------------------------------------------------------------- | ||
* Licensed under the terms set forth in the LICENSE.txt file, this | ||
* file is available at https://openusd.org/license. | ||
* | ||
* Copyright (C) 2016 Pixar. | ||
* Copyright (C) 2024 Wabi Foundation. All Rights Reserved. | ||
* ---------------------------------------------------------------- | ||
* . x x x . o o o . x x x . : : : . o x o . : : : . | ||
* ---------------------------------------------------------------- */ | ||
|
||
import Hdx | ||
|
||
private extension Hdx | ||
{ | ||
/** | ||
* Private struct to hold the static | ||
* data for the Hdx library. */ | ||
struct StaticData | ||
{ | ||
static let shared = StaticData() | ||
private init() | ||
{} | ||
|
||
let tokens = Pixar.HdxColorCorrectionTokens_StaticTokenType() | ||
} | ||
} | ||
|
||
public extension Hdx | ||
{ | ||
/** | ||
* # Hdx.Tokens | ||
* | ||
* ## Overview | ||
* | ||
* Public, client facing api to access | ||
* the static Hdx tokens. */ | ||
enum ColorCorrectionTokens: String, CaseIterable | ||
{ | ||
case sRGB | ||
|
||
public var token: Tf.Token | ||
{ | ||
switch self | ||
{ | ||
case .sRGB: StaticData.shared.tokens.sRGB | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* ---------------------------------------------------------------- | ||
* :: : M E T A V E R S E : :: | ||
* ---------------------------------------------------------------- | ||
* Licensed under the terms set forth in the LICENSE.txt file, this | ||
* file is available at https://openusd.org/license. | ||
* | ||
* Copyright (C) 2016 Pixar. | ||
* Copyright (C) 2024 Wabi Foundation. All Rights Reserved. | ||
* ---------------------------------------------------------------- | ||
* . x x x . o o o . x x x . : : : . o x o . : : : . | ||
* ---------------------------------------------------------------- */ | ||
|
||
import Foundation | ||
import PixarUSD | ||
|
||
public extension Hydra | ||
{ | ||
class Camera | ||
{ | ||
private let isZUp: Bool | ||
public var params = Params() | ||
|
||
public struct Params | ||
{ | ||
public var rotation = Pixar.GfVec3d(0.0) | ||
public var focus = Pixar.GfVec3d(0.0) | ||
public var distance = 50.0 | ||
public var focalLength = 0.0 | ||
public var projection = Pixar.GfCamera.Projection(0) | ||
public var leftBottomNear = Pixar.GfVec3d() | ||
public var rightTopFar = Pixar.GfVec3d() | ||
public var scaleViewport = 1.0 | ||
} | ||
|
||
public var position = Pixar.GfVec3d() | ||
public var standardFocalLength = Double() | ||
public var scaleBias = Double() | ||
|
||
public init(isZUp: Bool) | ||
{ | ||
self.isZUp = isZUp | ||
params.rotation = Pixar.GfVec3d(0.0) | ||
params.focus = Pixar.GfVec3d(0.0) | ||
params.distance = 50.0 | ||
params.scaleViewport = 1.0 | ||
} | ||
|
||
public func getTransform() -> GfMatrix4d | ||
{ | ||
let gfRotation = getRotation() | ||
var cameraTransform = GfMatrix4d(1.0) | ||
|
||
var gfMatrix = GfMatrix4d() | ||
|
||
cameraTransform = | ||
gfMatrix.SetTranslate(Pixar.GfVec3d(0.0, 0.0, params.distance)).pointee * | ||
gfMatrix.SetRotate(gfRotation).pointee * | ||
gfMatrix.SetTranslate(params.focus).pointee | ||
|
||
return cameraTransform | ||
} | ||
|
||
public func getRotation() -> Pixar.GfRotation | ||
{ | ||
var gfRotation = Pixar.GfRotation(Pixar.GfVec3d.ZAxis(), params.rotation[2]) * | ||
Pixar.GfRotation(Pixar.GfVec3d.XAxis(), params.rotation[0]) * | ||
Pixar.GfRotation(Pixar.GfVec3d.YAxis(), params.rotation[1]) | ||
|
||
if isZUp | ||
{ | ||
gfRotation = gfRotation * Pixar.GfRotation(Pixar.GfVec3d.XAxis(), 90.0) | ||
} | ||
|
||
return gfRotation | ||
} | ||
|
||
public func getShaderParams() -> Params | ||
{ | ||
return params | ||
} | ||
} | ||
} |
Oops, something went wrong.