Karana.Scene#
Classes and modules related to Scenes.
Submodules#
Attributes#
Classes#
Base interface for static geometry types |
|
Members: |
|
AbstractImport implementation using the third-party ASSIMP library |
|
Concrete box geometry class |
|
Concrete capsule geometry class (cylinder capped with hemispheres) |
|
Scene with added collision-specific interface |
|
Color class |
|
Concrete cone geometry class |
|
Concrete cylinder geometry class |
|
Scene with an added graphics-specific interface |
|
Texture specialization for grayscale values |
|
Info for a perspective camera projection |
|
A standard material with diffuse, ambient, specular, and emissive |
|
Parameter struct for a PhongMaterial |
|
A standard PBR material |
|
Parameter struct for a PhysicalMaterial |
|
Concrete round frustum geometry class |
|
Base for objects with a transform in the scene hierarchy |
|
Class for an object with geometry and material in the scene |
|
Concrete cylinder geometry class |
|
Concrete triangular mesh geometry class |
|
Style parameters for text |
|
Class for a texture image |
|
A Scene implementation acting as a proxy to any number of registered |
|
GraphicalScene implementation for web-based visualization |
|
CollisionScene implementation using the COAL library |
|
Functions#
|
|
|
Package Contents#
- class Karana.Scene.AbstractStaticGeometry#
Bases:
Karana.Core.BaseBase interface for static geometry types
- aabb() Karana.Math.AABB#
Compute the axis-aligned bounding box (AABB)
- Returns:
The AABB
- class Karana.Scene.Alignment(value: SupportsInt)#
Members:
LEFT
CENTER
RIGHT
- __eq__(other: Any) bool#
- __getstate__() int#
- __hash__() int#
- __index__() int#
- __int__() int#
- __ne__(other: Any) bool#
- __repr__() str#
- __setstate__(state: SupportsInt) None#
- __str__() str#
- property name: str#
- property value: int#
- class Karana.Scene.AssimpImporter#
AbstractImport implementation using the third-party ASSIMP library
- importFrom(filename: os.PathLike | str | bytes) ImportResult#
- class Karana.Scene.BoxGeometry(width: SupportsFloat, height: SupportsFloat, depth: SupportsFloat)#
Bases:
AbstractStaticGeometryConcrete box geometry class
- static to_json(o: BoxGeometry) dict[str, Any]#
Class method used to represent BoxGeometry in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a BoxGeometry from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a BoxGeometry from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent BoxGeometry in a yaml file.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [3, 1]]#
- __setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [3, 1]]) None#
- property depth: float#
side length in the z direction
- property height: float#
side length in the y direction
- property width: float#
side length in the x direction
- class Karana.Scene.CapsuleGeometry(radius: SupportsFloat, height: SupportsFloat)#
Bases:
AbstractStaticGeometryConcrete capsule geometry class (cylinder capped with hemispheres)
- static to_json(o: CapsuleGeometry) dict[str, Any]#
Class method used to represent CapsuleGeometry in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a CapsuleGeometry from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a CapsuleGeometry from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent CapsuleGeometry in a yaml file.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [2, 1]]#
- __setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [2, 1]]) None#
- property height: float#
height of the capsule’s middle section
- property radius: float#
radius of the capsule
- class Karana.Scene.CollisionInfo#
- static singleton() CollisionInfo#
- __bool__() bool#
- hasContact() bool#
- property part1: int#
- property part2: int#
- class Karana.Scene.CollisionScene#
Bases:
SceneScene with added collision-specific interface
- broadphase(callback: collections.abc.Callable[[CollisionScenePart, CollisionScenePart], None]) None#
Do a coarse sweep over the scene check for potential collisions.
- Parameter
callback: Function called for each potential collision
- Parameter
- cachedCollisions() list[CollisionInfo]#
Get a list of collisions from the last sweep
- Returns:
The cached collisions
- lookupPart(id: SupportsInt) CollisionScenePart#
Fetch a part by its id
- Returns:
The part
- sweep(callback: collections.abc.Callable[[CollisionInfo], None], filter: collections.abc.Callable[[CollisionScenePart, CollisionScenePart], bool] = None) None#
Do a sweep over the scene checking for collisions
- Parameter
callback: Function called for each collision
- Parameter
filter: Filter function called for each potiential collision pair
- Parameter
- class Karana.Scene.CollisionScenePart#
Bases:
ScenePart,CollisionSceneNode- collide(other: CollisionScenePart) CollisionInfo#
- collide(other: CollisionScenePart, result: CollisionInfo) CollisionInfo
- distance(other: CollisionScenePart) DistanceInfo#
- distance(other: CollisionScenePart, result: DistanceInfo) DistanceInfo
- class Karana.Scene.Color(other: Color)#
Color class
- static fromHex(hex_str: str, alpha: SupportsFloat = 1.0) Color#
Create a color from a hex string and opacity
The hex_str input is parsed to extract red, green, and blue components. For example, “ff0000” and “f00” are pure red.
- Parameter
hex_str: a 3 or 6 length hex string
- Parameter
alpha: the opacity factor between 0 and 1
- Returns:
the created Color
- Parameter
- static fromRGB(r: SupportsFloat, g: SupportsFloat, b: SupportsFloat) Color#
Create an opaque color from rgb components
- Parameter
r: the red component between 0 and 1
- Parameter
g: the green component between 0 and 1
- Parameter
b: the blue component between 0 and 1
- Returns:
the created Color
- Parameter
- static fromRGBA(r: SupportsFloat, g: SupportsFloat, b: SupportsFloat, alpha: SupportsFloat) Color#
Create a color from rgb components and opacity
- Parameter
r: the red component between 0 and 1
- Parameter
g: the green component between 0 and 1
- Parameter
b: the blue component between 0 and 1
- Parameter
alpha: the opacity factor between 0 and 1
- Returns:
the created Color
- Parameter
- classmethod from_json(d: dict[str, Any]) Self#
Construct a Color from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a Color from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent Color in a yaml file.
- __assign__(other: Color) Color#
Copy assignment operator
- Parameter
other: the Color to copy
- Returns:
this Color
- Parameter
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [4, 1]]#
- __repr__() str#
- __setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [4, 1]]) None#
- alpha() float#
Get the alpha (opacity) value
- Returns:
The alpha value
- b() float#
Get the blue component
- Returns:
The blue component
- g() float#
Get the green component
- Returns:
The green component
- r() float#
Get the red component
- Returns:
The red component
- class Karana.Scene.ConeGeometry(radius: SupportsFloat, height: SupportsFloat)#
Bases:
AbstractStaticGeometryConcrete cone geometry class
- static to_json(o: ConeGeometry) dict[str, Any]#
Class method used to represent ConeGeometry in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a ConeGeometry from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a ConeGeometry from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent ConeGeometry in a yaml file.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [2, 1]]#
- __setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [2, 1]]) None#
- property height: float#
height of the cone
- property radius: float#
radius of the cone
- class Karana.Scene.Contact#
- property normal: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- property penetration: float#
- property witness1: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- property witness2: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- class Karana.Scene.CylinderGeometry(radius: SupportsFloat, height: SupportsFloat)#
Bases:
AbstractStaticGeometryConcrete cylinder geometry class
- static to_json(o: CylinderGeometry) dict[str, Any]#
Class method used to represent CylinderGeometry in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a CylinderGeometry from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a CylinderGeometry from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent CylinderGeometry in a yaml file.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [2, 1]]#
- __setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [2, 1]]) None#
- property height: float#
height of the cylinder
- property radius: float#
radius of the cylinder
- class Karana.Scene.DistanceInfo#
- static singleton() DistanceInfo#
- property distance: float#
- property nearest1: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- property nearest2: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- class Karana.Scene.GraphicalScene#
Bases:
SceneScene with an added graphics-specific interface
- addOverlayText(arg0: str, arg1: SupportsFloat, arg2: SupportsFloat, arg3: TextParameters) int#
- addOverlayText(message: str, x: SupportsFloat, y: SupportsFloat, align: Alignment = Alignment.LEFT, size: SupportsFloat = 0.05000000074505806, color: Color = ...) int
Add text in screen space
- Parameter
message: The content of the overlay text
- Parameter
x: The horizontal position of the text between 0 and 1
- Parameter
y: The vertical position of the text between 0 and 1
- Parameter
parameters: Addition text parameters
- Returns:
Unique id to later update the text instance
- Parameter
- defaultCamera() GraphicalSceneCamera#
Get the automatically created default camera
- Returns:
The default camera
- removeOverlayText(arg0: SupportsInt) None#
Add text in screen space
- Parameter
message: The content of the overlay text
- Parameter
x: The horizontal position of the text between 0 and 1
- Parameter
y: The vertical position of the text between 0 and 1
- Parameter
parameters: Addition text parameters
- Returns:
Unique id to later update the text instance
- Parameter
- renderToFile(arg0: str) None#
Render the scene to a file
- Parameter
filepath: filename to render to
- Parameter
- setOverlayText(arg0: SupportsInt, arg1: str) None#
Add text in screen space
- Parameter
message: The content of the overlay text
- Parameter
x: The horizontal position of the text between 0 and 1
- Parameter
y: The vertical position of the text between 0 and 1
- Parameter
parameters: Addition text parameters
- Returns:
Unique id to later update the text instance
- Parameter
- class Karana.Scene.GraphicalSceneCamera#
Bases:
GraphicalSceneNode- getMask() int#
Get the bitmask for which layers should be visible.
- Returns:
The layers bitmask
- getProjection() PerspectiveProjection | OrthographicProjection#
Get the camera projection parameters
- Returns:
The camera projection parameters
- pointCameraAt(offset: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]], target: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]], up: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
Set the pose of the camera.
- Parameter
offset: The position of the camera.
- Parameter
target: The position the camera will point at.
- Parameter
up: The up vector of the camera.
- Parameter
- setMask(mask: SupportsInt) None#
Set the bitmask for which layers should be visible.
- Parameter
mask: The layers bitmask
- Parameter
- setProjection(projection: PerspectiveProjection | OrthographicProjection) None#
Set the camera projection parameters
- Parameter
proj: The camera projection parameters
- Parameter
- class Karana.Scene.GraphicalSceneNode#
Bases:
SceneNode- removeTrail() None#
Remove a trail previously created by calling trail
- showAxes(size: SupportsFloat = 1.0) None#
Show axes to visualize the node’s position and orientation
- Parameter
size: Lengths of the axes (zero to remove the axes)
- Parameter
- trail(reference: GraphicalSceneNode = None, color: Color = ...) None#
Display a trail tracking the node’s motion over time.
- Parameter
relative_to: Another node to draw the trail relative to.
- Parameter
color: The color of the Trail.
- Parameter
- class Karana.Scene.GraphicalScenePart#
Bases:
ScenePart,GraphicalSceneNode
- class Karana.Scene.GrayscaleTexture#
Bases:
TextureTexture specialization for grayscale values
- static lookupOrCreateTexture(filename: os.PathLike | str | bytes) GrayscaleTexture#
Create a texture from a file name. This caches the texture so that future versions created with the same file name just return a pointer to the same texture.
- Parameter
filename: The name of the file.
- Returns:
A ks_ptr to the GrayscaleTexture.
- Parameter
- static to_json(o: GrayscaleTexture) dict[str, Any]#
Class method used to represent GrayscaleTexture in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a GrayscaleTexture from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a GrayscaleTexture from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent GrayscaleTexture in a yaml file.
- __getstate__() tuple#
- __setstate__(arg0: tuple) None#
- class Karana.Scene.ImportResult#
- property geometries: list[BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | StaticMeshGeometry | AbstractStaticGeometry]#
- property materials: list[PhysicalMaterial | PhongMaterial]#
- property parts: list[ScenePartSpec]#
- Karana.Scene.LAYER_ALL: int = 4294967295#
- Karana.Scene.LAYER_COLLISION: int = 134217728#
- Karana.Scene.LAYER_CUSTOM0: int = 1#
- Karana.Scene.LAYER_CUSTOM1: int = 2#
- Karana.Scene.LAYER_CUSTOM10: int = 1024#
- Karana.Scene.LAYER_CUSTOM11: int = 2048#
- Karana.Scene.LAYER_CUSTOM12: int = 4096#
- Karana.Scene.LAYER_CUSTOM13: int = 8192#
- Karana.Scene.LAYER_CUSTOM14: int = 16384#
- Karana.Scene.LAYER_CUSTOM15: int = 32768#
- Karana.Scene.LAYER_CUSTOM16: int = 65536#
- Karana.Scene.LAYER_CUSTOM17: int = 131072#
- Karana.Scene.LAYER_CUSTOM18: int = 262144#
- Karana.Scene.LAYER_CUSTOM19: int = 524288#
- Karana.Scene.LAYER_CUSTOM2: int = 4#
- Karana.Scene.LAYER_CUSTOM20: int = 1048576#
- Karana.Scene.LAYER_CUSTOM21: int = 2097152#
- Karana.Scene.LAYER_CUSTOM22: int = 4194304#
- Karana.Scene.LAYER_CUSTOM23: int = 8388608#
- Karana.Scene.LAYER_CUSTOM3: int = 8#
- Karana.Scene.LAYER_CUSTOM4: int = 16#
- Karana.Scene.LAYER_CUSTOM5: int = 32#
- Karana.Scene.LAYER_CUSTOM6: int = 64#
- Karana.Scene.LAYER_CUSTOM7: int = 128#
- Karana.Scene.LAYER_CUSTOM8: int = 256#
- Karana.Scene.LAYER_CUSTOM9: int = 512#
- Karana.Scene.LAYER_GRAPHICS: int = 117440512#
- Karana.Scene.LAYER_NONE: int = 0#
- Karana.Scene.LAYER_ORNAMENTAL: int = 33554432#
- Karana.Scene.LAYER_PHYSICAL: int = 150994944#
- Karana.Scene.LAYER_PHYSICAL_GRAPHICS: int = 16777216#
- Karana.Scene.LAYER_RESERVED0: int = 16777216#
- Karana.Scene.LAYER_RESERVED1: int = 33554432#
- Karana.Scene.LAYER_RESERVED2: int = 67108864#
- Karana.Scene.LAYER_RESERVED3: int = 134217728#
- Karana.Scene.LAYER_RESERVED4: int = 268435456#
- Karana.Scene.LAYER_RESERVED5: int = 536870912#
- Karana.Scene.LAYER_RESERVED6: int = 1073741824#
- Karana.Scene.LAYER_RESERVED7: int = 2147483648#
- Karana.Scene.LAYER_STICK_FIGURE: int = 67108864#
- class Karana.Scene.OrthographicProjection#
- property far: float#
distance to far clipping plane
- property height: float#
distance between top and bottom viewing planes
- property near: float#
distance to near clipping plane
- class Karana.Scene.PerspectiveProjection#
Info for a perspective camera projection
- property far: float#
distance to far clipping plane
- property fov: float#
vertical field of view in degrees
- property near: float#
distance to near clipping plane
- class Karana.Scene.PhongMaterial(mat: PhongMaterialInfo)#
Bases:
Karana.Core.BaseA standard material with diffuse, ambient, specular, and emissive components
- static create(mat: PhongMaterialInfo) PhongMaterial#
Create a PhongMaterial
- Parameter
mat: the parameter struct
- Returns:
The created PhongMaterial
- Parameter
- static to_json(o: PhongMaterial) dict[str, Any]#
Class method used to represent PhongMaterial in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a PhongMaterial from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a PhongMaterial from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent PhongMaterial in a yaml file.
- __getstate__() PhongMaterialInfo#
- __setstate__(arg0: PhongMaterialInfo) None#
- property info: PhongMaterialInfo#
Parameters for the materials
- class Karana.Scene.PhongMaterialInfo#
Parameter struct for a PhongMaterial
- static to_json(o: PhongMaterialInfo) dict[str, Any]#
Class method used to represent PhongMaterialInfo in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a PhongMaterialInfo from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a PhongMaterialInfo from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent PhongMaterialInfo in a yaml file.
- __getstate__() tuple#
- __setstate__(arg0: tuple) None#
- class Karana.Scene.PhysicalMaterial(mat: PhysicalMaterialInfo)#
Bases:
Karana.Core.BaseA standard PBR material
- static create(mat: PhysicalMaterialInfo) PhysicalMaterial#
Create a PhysicalMaterial
- Parameter
mat: the parameter struct
- Returns:
The created PhysicalMaterial
- Parameter
- static to_json(o: PhysicalMaterial) dict[str, Any]#
Class method used to represent PhysicalMaterial in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a PhysicalMaterial from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a PhysicalMaterial from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent PhysicalMaterial in a yaml file.
- __getstate__() PhysicalMaterialInfo#
- __setstate__(arg0: PhysicalMaterialInfo) None#
- property info: PhysicalMaterialInfo#
Parameters for the materials
- class Karana.Scene.PhysicalMaterialInfo#
Parameter struct for a PhysicalMaterial
- static to_json(o: PhysicalMaterialInfo) dict[str, Any]#
Class method used to represent PhysicalMaterialInfo in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a PhysicalMaterialInfo from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a PhysicalMaterialInfo from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent PhysicalMaterialInfo in a yaml file.
- __getstate__() tuple#
- __setstate__(arg0: tuple) None#
- property metalness: float#
how metal-like the material is, between 0 and 1
- property metalnessMap: GrayscaleTexture#
grayscale metalness map
- property roughness: float#
how rough the material is, between 0 and 1
- property roughnessMap: GrayscaleTexture#
grayscale roughness map
- class Karana.Scene.RoundFrustumGeometry(bottomRadius: SupportsFloat, topRadius: SupportsFloat, height: SupportsFloat)#
Bases:
AbstractStaticGeometryConcrete round frustum geometry class
- static to_json(o: RoundFrustumGeometry) dict[str, Any]#
Class method used to represent RoundFrustumGeometry in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a RoundFrustumGeometry from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a RoundFrustumGeometry from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent RoundFrustumGeometry in a yaml file.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [3, 1]]#
- __setstate__(arg0: Annotated[numpy.typing.ArrayLike, numpy.float32, [3, 1]]) None#
- property bottomRadius: float#
radius of the bottom face
- property height: float#
height of the frustum
- property topRadius: float#
radius of the top face
- class Karana.Scene.Scene#
Bases:
Karana.Core.Base
- class Karana.Scene.SceneNode#
Bases:
Karana.Core.BaseBase for objects with a transform in the scene hierarchy
- attachTo(parent: SceneNode, maintain_world_transform: bool = False) None#
Attach to a parent node
- Parameter
parent: The parent node
- Parameter
maintain_world_transform: If true, update the node’s relative transform so that its
overall world transform doesn’t change after attaching it to the parent
- Parameter
- detach(maintain_world_transform: bool = False) None#
Detach the node from its parent
- Parameter
maintain_world_transform: If true, update the node’s relative transform so that its
overall world transform doesn’t change after detaching
- Parameter
- getScale() float#
Get uniform scale of the node relative to its parent
- Returns:
The relative uniform scale
- getTranslation() Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Get position of the node relative to its parent
- Returns:
The relative translation
- getUnitQuaternion() Karana.Math.UnitQuaternion#
Get rotation of the node relative to its parent
- Returns:
The relative rotation as a unit quaternion
- getVisible() bool#
Get whether the object is visible
- Returns:
The visibility flag
- getWorldScale() float#
Get uniform scale of the node relative to the scene’s root
- Returns:
The uniform scale
- getWorldTransform() Karana.Math.SimTran#
Get similarity transform of the node relative to the scene’s root
- Returns:
The similarity transform
- getWorldTranslation() Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Get translation of the node relative to the scene’s root
- Returns:
The translation
- getWorldUnitQuaternion() Karana.Math.UnitQuaternion#
Get rotation of the node relative to the scene’s root
- Returns:
The rotation as a unit quaternion
- setScale(scale: SupportsFloat) None#
Set uniform of the node relative to its parent
- Parameter
scale: The relative uniform scale
- Parameter
- setTranslation(translation: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
Set position of the node relative to its parent
- Parameter
translation: The relative translation
- Parameter
- setUnitQuaternion(quaternion: Karana.Math.UnitQuaternion) None#
Set rotation of the node relative to its parent
- Parameter
quaternion: The relative rotation as a unit quaternion
- Parameter
- setVisible(visible: bool) None#
Set whether the object is visible
- Parameter
visible: The visibility flag
- Parameter
- class Karana.Scene.ScenePart#
Bases:
SceneNodeClass for an object with geometry and material in the scene
- getGeometry() BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | StaticMeshGeometry | AbstractStaticGeometry#
Get the part’s geometry
- Returns:
The part’s geometry
- getIntrinsicScale() Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
Get the part’s intrinsic scale.
The intrinsic scale can be non-uniform but does not apply to attached nodes.
- Returns:
The part’s intrinsic scale.
- getMaterial() PhysicalMaterial | PhongMaterial#
Get the part’s material
- Returns:
The part’s material
- setIntrinsicScale(arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
Set the part’s intrinsic scale.
The intrinsic scale can be non-uniform but does not apply to attached nodes.
- Parameter
scale: The part’s intrinsic scale.
- Parameter
- setMaterial(arg0: PhysicalMaterial | PhongMaterial) None#
Set the part’s material
- Parameter
material: The part’s new material.
- Parameter
- class Karana.Scene.ScenePartSpec#
- geometry: BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | StaticMeshGeometry | AbstractStaticGeometry#
- material: PhysicalMaterial | PhongMaterial#
- name: str#
- transform: Karana.Math.HomTran#
- property layers: int#
- property scale: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- class Karana.Scene.SphereGeometry(radius: SupportsFloat)#
Bases:
AbstractStaticGeometryConcrete cylinder geometry class
- static to_json(o: SphereGeometry) dict[str, Any]#
Class method used to represent SphereGeometry in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a SphereGeometry from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a SphereGeometry from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent SphereGeometry in a yaml file.
- __getstate__() float#
- __setstate__(arg0: SupportsFloat) None#
- property radius: float#
radius of the sphere
- class Karana.Scene.StaticMeshGeometry(positions: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, 3]], faces: Annotated[numpy.typing.ArrayLike, numpy.int32, [m, 3]], normals: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, 3]], surface_map_coords: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, 2]])#
Bases:
AbstractStaticGeometryConcrete triangular mesh geometry class
- static to_json(o: StaticMeshGeometry) dict[str, Any]#
Class method used to represent StaticMeshGeometry in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a StaticMeshGeometry from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a StaticMeshGeometry from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent StaticMeshGeometry in a yaml file.
- __getstate__() tuple#
- __setstate__(arg0: tuple) None#
- property faces: Annotated[numpy.typing.NDArray[numpy.int32], [m, 3]]#
triangles consisting of three vertex indices
- property filename: str#
If this mesh comes from a file, this is the filename.
- property normals: Annotated[numpy.typing.NDArray[numpy.float32], [m, 3]]#
vertex normals
- property positions: Annotated[numpy.typing.NDArray[numpy.float32], [m, 3]]#
vertex positions
- property surface_map_coords: Annotated[numpy.typing.NDArray[numpy.float32], [m, 2]]#
vertex uv (texture) coordinates
- class Karana.Scene.TextParameters#
Style parameters for text
- property size: float#
Text size as a portion of the screen’s full vertical space
- class Karana.Scene.Texture#
Bases:
Karana.Core.BaseClass for a texture image
- static create(name: str, data: Annotated[numpy.typing.ArrayLike, numpy.int8]) Texture#
Create a Texture instance.
- Parameter
name: The Texture’s name.
- Parameter
data: The data for the texture.
- Returns:
A ks_ptr to the Texture.
- Parameter
- static lookupOrCreateTexture(filename: os.PathLike | str | bytes) Texture#
Create a texture from a file name. This caches the texture so that future versions created with the same file name just return a pointer to the same texture.
- Parameter
filename: The name of the file.
- Returns:
A ks_ptr to the Texture.
- Parameter
- classmethod from_json(d: dict[str, Any]) Self#
Construct a Texture from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a Texture from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent Texture in a yaml file.
- __getstate__() tuple#
- __setstate__(arg0: tuple) None#
- getData() numpy.ndarray#
Get the texture data associated with the Texture.
- Returns:
The texture data associated with the Texture.
- setData(data: Annotated[numpy.typing.ArrayLike, numpy.int8]) None#
Set the texture data associated with the Texture.
- Parameter
data: The data to set the Texture data to.
- Parameter
- writeToFile(filename: os.PathLike | str | bytes) None#
Write the texture to a file.
- Parameter
filename: The name of the file to write to.
- Parameter
- Karana.Scene.defaultGeometry() BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | StaticMeshGeometry | AbstractStaticGeometry#
- Karana.Scene.defaultMaterial() PhysicalMaterial | PhongMaterial#
- class Karana.Scene.ProxyScene(name: str, root_frame: Karana.Frame.Frame)#
Bases:
Karana.Scene.SceneA Scene implementation acting as a proxy to any number of registered ‘client’ Scenes.
- update_callbacks: Karana.Core._KCore_pybind11_Py._VoidCallbackRegistry#
- static create(name: str, root_frame: Karana.Frame.Frame) ProxyScene#
Create a ProxyScene
- Parameter
name: Name of the ProxyScene.
- Parameter
root_frame: Default Frame to attach nodes to.
- Returns:
The created ProxyScene
- Parameter
- collision() Karana.Scene.CollisionScene#
Get a registered CollisionScene
If there is more than one only the first one found is returned.
- Returns:
A CollisionScene or nullptr
- getNodesAttachedToFrame(arg0: Karana.Frame.Frame) list[ProxySceneNode]#
Retrieve all ProxySceneNodes attached to the provided frame.
- Parameter
frame: The frame to retrieve nodes from.
- Returns:
A vector of ProxySceneNodes attached to the provided frame.
- Parameter
- graphics() Karana.Scene.GraphicalScene#
Get a registered GraphicalScene
If there is more than one only the first one found is returned.
- Returns:
A GraphicalScene or nullptr
- lookupProxyFromImpl(impl: Karana.Scene.SceneNode) ProxySceneNode#
Lookup the ProxySceneNode managing the given implementation
- Parameter
impl: The SceneNode in a client Scene
- Returns:
The corresponding ProxySceneNode
- Parameter
- registerClientScene(scene: Karana.Scene.Scene, origin_frame: Karana.Frame.Frame, layers: SupportsInt = 4294967295) None#
Register a client Scene to be managed
- Parameter
scene: The client Scene
- Parameter
origin_frame: The Frame to center the client’s origin at
- Parameter
layers: Bitmask for objects to implement
- Parameter
- showAxes(frame: Karana.Frame.Frame, size: SupportsFloat = 1.0) None#
Show the axes for a Frame
- Parameter
frm: the Frame to show axes for
- Parameter
size: the size of the axes
- Parameter
- unregisterClientScene(arg0: Karana.Scene.Scene) None#
Unregister a client Scene to no longer be managed
- Parameter
scene: The client Scene.
- Parameter
- update() None#
- update(arg0: Karana.Scene.Scene) None
Update all Frame-attached nodes’ transforms for all clients
- class Karana.Scene.ProxySceneNode(name: str, scene: ProxyScene)#
Bases:
Karana.Scene.SceneNode- attachTo(parent: Karana.Scene.SceneNode, maintain_world_transform: bool = False) None#
- attachTo(parent: Karana.Frame.Frame, maintain_world_transform: bool = False) None
Attach the node to a Frame
- Parameter
parent: The Frame to attach to
- Parameter
maintain_world_transform: If true, update the node’s relative transform so that its
overall world transform doesn’t change after attaching it to the parent
- Parameter
- collision() Karana.Scene.CollisionSceneNode#
- collision(arg0: Karana.Scene.Scene) Karana.Scene.CollisionSceneNode
Get a collision implementation If there is more than one collision implementation only the first one found is returned.
- Returns:
A collision implementation or nullptr
- create(name: Karana.Frame.Frame) ProxyScene#
Create a ProxyScene node.
- Parameter
name: The name of the ProxySceneNode.
- Parameter
scene: The ProxyScene to add the node to.
- Returns:
The created ProxySceneNode
- Parameter
- detach(maintain_world_transform: bool = False) None#
- graphics() Karana.Scene.GraphicalSceneNode#
- graphics(arg0: Karana.Scene.Scene) Karana.Scene.GraphicalSceneNode
Get a graphical implementation If there is more than one graphical implementation only the first one found is returned.
- Returns:
A graphical implementation or nullptr
- of(scene: Karana.Scene.Scene) Karana.Scene.SceneNode#
Get the implementation for a given client
- Parameter
scene: The client scene
- Returns:
The implementation of this node for the client
- Parameter
- setScale(arg0: SupportsFloat) None#
- setTranslation(arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
- setUnitQuaternion(arg0: Karana.Math.UnitQuaternion) None#
- class Karana.Scene.ProxyScenePart(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: ProxyScene, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt = 150994944)#
- class Karana.Scene.ProxyScenePart(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: ProxyScene, layers: SupportsInt = 150994944)
Bases:
Karana.Scene.ScenePart,ProxySceneNode- static create(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: ProxyScene, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt = 150994944) ProxyScenePart#
- static create(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: ProxyScene, layers: SupportsInt = 150994944) ProxyScenePart
Create a ProxyScenePart.
- Parameter
name: Name of the ProxyScenePart.
- Parameter
geometry: Geometry of the ProxyScenePart.
- Parameter
scene: The ProxyScene to add the ProxyScenePart to.
- Parameter
material: Material for the ProxyScenePart.
- Parameter
layers: Layers to use for the ProxyScenePart.
- Returns:
The new ProxyScene part.
- Parameter
- static fromScenePartSpec(scene: ProxyScene, spec: Karana.Scene.ScenePartSpec) ProxyScenePart#
Create a ProxyScenePart from a ScenePartSpec.
- Parameter
scene: The ProxyScene to add the ProxyScenePart to.
- Parameter
spec: The spec to use to create the ProxyScenePart.
- Returns:
The new ProxyScene part.
- Parameter
- collision() Karana.Scene.CollisionScenePart#
- collision(arg0: Karana.Scene.Scene) Karana.Scene.CollisionScenePart
Get a collision implementation If there is more than one collision implementation only the first one found is returned.
- Returns:
A collision implementation or nullptr
- graphics() Karana.Scene.GraphicalScenePart#
- graphics(arg0: Karana.Scene.Scene) Karana.Scene.GraphicalScenePart
Get a graphical implementation If there is more than one graphical implementation only the first one found is returned.
- Returns:
A graphical implementation or nullptr
- of(scene: Karana.Scene.Scene) Karana.Scene.ScenePart#
Get the implementation for a given client
- Parameter
scene: The client scene
- Returns:
The implementation of this node for the client
- Parameter
- setIntrinsicScale(arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
- class Karana.Scene.WebScene(name: str, server: Karana.WebUI.Server)#
Bases:
Karana.Scene.GraphicalSceneGraphicalScene implementation for web-based visualization
- static create(name: str, server: Karana.WebUI.Server) WebScene#
Create a WebScene
- Parameter
name: Name for the WebScene
- Parameter
server: Server to communicate with frontends
- Returns:
The created WebScene
- Parameter
- defaultCamera() Karana.Scene.GraphicalSceneCamera#
Get the default camera
- Returns:
The camera
- renderToFile(filepath: str) None#
- class Karana.Scene.WebSceneNode(name: str, scene: WebScene)#
Bases:
Karana.Scene.GraphicalSceneNode- static create(name: str, scene: WebScene) WebSceneNode#
Create a WebSceneNode.
- Parameter
name: Name of the node.
- Parameter
scene: The WebScene to add the node to.
- Returns:
The created WebSceneNode.
- Parameter
- class Karana.Scene.WebScenePart(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: WebScene, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt = 150994944)#
- class Karana.Scene.WebScenePart(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: WebScene, layers: SupportsInt = 150994944)
Bases:
Karana.Scene.GraphicalScenePart,WebSceneNode- static create(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: WebScene, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt = 150994944) WebScenePart#
- static create(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: WebScene, layers: SupportsInt = 150994944) WebScenePart
Create a WebScenePart.
- Parameter
name: Name of the WebScenePart.
- Parameter
geometry: Geometry of the WebScenePart.
- Parameter
scene: The GraphicalScene to add the WebScenePart to.
- Parameter
material: Material for the WebScenePart.
- Parameter
layers: Layers to use for the WebScenePart.
- Returns:
The new WebScene part.
- Parameter
- getIntrinsicScale() Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- setIntrinsicScale(arg0: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
- class Karana.Scene.CoalScene(name: str)#
Bases:
Karana.Scene.CollisionSceneCollisionScene implementation using the COAL library
- class Karana.Scene.CoalSceneNode(name: str, scene: CoalScene)#
Bases:
Karana.Scene.CollisionSceneNode- static create(name: str, scene: CoalScene) CoalSceneNode#
Create a CoalSceneNode.
- Parameter
name: The name of the CoalSceneNode.
- Parameter
scene: The CoalScene to add the node to.
- Returns:
The created CoalSceneNode.
- Parameter
- class Karana.Scene.CoalScenePart(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: CoalScene, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt = 150994944)#
- class Karana.Scene.CoalScenePart(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: CoalScene, layers: SupportsInt = 150994944)
Bases:
CoalSceneNode,Karana.Scene.CollisionScenePart- static create(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: CoalScene, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial, layers: SupportsInt = 150994944) CoalScenePart#
- static create(name: str, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, scene: CoalScene, layers: SupportsInt = 150994944) CoalScenePart
Create a CoalScenePart.
- Parameter
name: Name of the CoalScenePart.
- Parameter
geometry: Geometry of the CoalScenePart.
- Parameter
scene: The GraphicalScene to add the CoalScenePart to.
- Parameter
material: Material for the CoalScenePart.
- Parameter
layers: Layers to use for the CoalScenePart.
- Returns:
The new CoalScene part.
- Parameter