Karana.Scene#
Classes and modules related to Scenes.
Submodules#
Attributes#
Classes#
Interface for static geometry types |
|
Text alignment/justification type |
|
Exporter implementation backed by the third-party ASSIMP library. |
|
AbstractImport implementation using the third-party ASSIMP library |
|
Concrete box geometry class |
|
Geometry class for a cylinder capped with hemispheres |
|
Scene with added collision-specific interface |
|
Base for objects with a transform i n the scene hierarchy |
|
Class for objects with geometry and material in the scene |
|
Color class |
|
Concrete cone geometry class |
|
Concrete cylinder geometry class |
|
Scene with an added graphics-specific interface |
|
Base for objects with a transform i n the scene hierarchy |
|
Base for objects with a transform i n the scene hierarchy |
|
Class for objects with geometry and material in the scene |
|
Texture specialization for grayscale values |
|
Northwest-origin 2D heightfield with fixed X/Y extents and sampled Z |
|
Info for an orthographic camera projection |
|
Info for a perspective camera projection |
|
A standard Phong material |
|
Parameter struct for a PhongMaterial |
|
A standard PBR material |
|
Parameter struct for a PhysicalMaterial |
|
Concrete round frustum geometry class |
|
Base container for a hierarchy of geometries |
|
Class for an opaque node with contents loaded from a file. |
|
The Vars for the SceneFileObject class. |
|
Base for objects with a transform i n the scene hierarchy |
|
Class for objects with geometry and material in the scene |
|
The Vars for the ScenePartSpec class. |
|
The Vars for the ScenePart class. |
|
Concrete sphere geometry class |
|
Concrete triangular mesh geometry class |
|
Style parameters for text |
|
Class for a texture image |
|
RAII wrapper for beginTransformUpdates and endTransformUpdates |
|
A Wireframe material |
|
Parameter struct for a WireframeMaterial |
|
A Scene implementation acting as a proxy to any number of registered |
|
The Vars for the ProxySceneFileObject class. |
|
The Vars for the ProxyScenePart class. |
|
GraphicalScene implementation for web-based graphics |
|
CollisionScene implementation using the COAL library |
|
SceneFileObject implementation for CoalScene |
|
CollisionSceneNode implementation for CoalScene |
|
CollisionScenePart implementation for CoalScene |
Functions#
|
Print values for Python scripts. |
Context to print numpy values with full precision. |
|
|
Decompose a triangle mesh into a union of convex hulls using the COACD library. |
|
Get a graph coloring for subhulls resulting from a convex decomposition. |
|
|
|
Package Contents#
- class Karana.Scene.VarPythonScriptContext[source]#
- Karana.Scene.valuePrinter(q) str[source]#
Print values for Python scripts.
- Parameters:
q (Quantity | NDArray) – The value to print
- Returns:
The string representation of the value.
- Return type:
- Karana.Scene.getConvexDecomposition(geom: StaticMeshGeometry, coacd_args: dict | None = None, verbose: bool = False, dupe_vertices: bool = True) list[StaticMeshGeometry]#
Decompose a triangle mesh into a union of convex hulls using the COACD library.
- Parameters:
geom (StaticMeshGeometry) – Original mesh to decompose.
- Returns:
List of StaticMeshGeometry objects corresponding to each subhull.
- Return type:
- Karana.Scene.colorConvexDecomposition(geoms: list[StaticMeshGeometry], eps: float = 0.001) list[tuple[float, float, float]]#
Get a graph coloring for subhulls resulting from a convex decomposition.
- class Karana.Scene.AbstractStaticGeometry#
Bases:
Karana.Core.BaseWithVarsInterface for static geometry types
See Scene layer for more discussion on the scene layer.
- aabb() Karana.Math.AABB#
Compute the axis-aligned bounding box (AABB)
- Returns:
The AABB
- computeMesh() StaticMeshGeometry#
Convert to a triangular mesh
- Returns:
The converted mesh
- class Karana.Scene.AssimpExporter#
Exporter implementation backed by the third-party ASSIMP library.
AssimpExporter converts every ScenePartSpec to a triangulated Assimp mesh and writes an Assimp scene to disk. The exporter calls AbstractStaticGeometry::computeMesh() for each geometry, so built-in primitives, height fields, imported meshes, and user-defined static geometry all share the same output path.
Materials are emitted as simple diffuse/specular or PBR-style scalar colors when the selected Assimp format supports them. Texture maps are referenced by filepath when they were created through kdFlex texture cache APIs and Texture::lookupFilepath() or GrayscaleTexture::lookupFilepath() can resolve the source image path.
- exportTo(filename: os.PathLike | str | bytes, parts: collections.abc.Sequence[ScenePartSpec]) None#
Export scene part specifications through Assimp.
- Parameters:
filename – Destination file. If no explicit format id was configured, the extension is mapped to an Assimp exporter id such as “obj”, “collada”, or “gltf2”.
parts – ScenePartSpec collection to write.
- Raises:
std::invalid_argument – when the filename has no supported format extension.
std::runtime_error – when Assimp rejects or cannot write the scene.
- class Karana.Scene.AssimpImporter#
AbstractImport implementation using the third-party ASSIMP library
See Scene layer for more discussion on the scene layer.
- importFrom(filename: os.PathLike | str | bytes, is_convex: bool = False) ImportResult#
- class Karana.Scene.BoxGeometry(width: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex, depth: SupportsFloat | SupportsIndex)#
Bases:
AbstractStaticGeometryConcrete box geometry class
See Scene layer for more discussion on the scene layer.
- static create(width: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex, depth: SupportsFloat | SupportsIndex) BoxGeometry#
Create a new instance of BoxGeometry from side-lengths.
- Parameters:
width – side length in the x direction
height – side length in the y direction
depth – side length in the z direction
- Returns:
A pointer to the newly created instance of BoxGeometry.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [3, 1]]#
- computeMesh() StaticMeshGeometry#
Convert to a triangular mesh
- Returns:
The converted mesh
- classmethod to_yaml(representer, node)#
Class method used to represent BoxGeometry in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a BoxGeometry from yaml file data.
- static to_json(o: BoxGeometry) dict[str, Any]#
Class method used to represent BoxGeometry in a json file.
- class Karana.Scene.CapsuleGeometry(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex)#
Bases:
AbstractStaticGeometryGeometry class for a cylinder capped with hemispheres
See Scene layer for more discussion on the scene layer.
- static create(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) CapsuleGeometry#
Create a new instance of CapsuleGeometry from radius and height.
- Parameters:
radius – radius of the capsule
height – height of the capsule’s middle section
- Returns:
A pointer to the newly created instance of BoxGeometry.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [2, 1]]#
- classmethod to_yaml(representer, node)#
Class method used to represent CapsuleGeometry in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a CapsuleGeometry from yaml file data.
- static to_json(o: CapsuleGeometry) dict[str, Any]#
Class method used to represent CapsuleGeometry in a json file.
- class Karana.Scene.CollisionInfo#
- static singleton() CollisionInfo#
- class Karana.Scene.CollisionScene#
Bases:
SceneScene with added collision-specific interface
See Scene layer for more discussion on the scene layer.
- broadphase(callback: collections.abc.Callable[[CollisionScenePart, CollisionScenePart], None]) None#
Do a coarse sweep over the scene check for potential collisions.
- Parameters:
callback –
Function called for each potential collision
- cachedCollisions() list[CollisionInfo]#
Get a list of collisions from the last sweep
- Returns:
The cached collisions
- lookupPart(id: SupportsInt | SupportsIndex) 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
- Parameters:
callback –
Function called for each collision
filter –
Filter function called for each potential collision pair
- toDS() Karana.Scene.Scene_types.CollisionSceneDS#
Create a CollisionSceneDS from this CollisionScene model.
- Returns:
CollisionSceneDS
A CollisionSceneDS instance with values set to match this model.
- class Karana.Scene.CollisionSceneNode#
Bases:
SceneNodeBase for objects with a transform i n the scene hierarchy
See Scene layer for more discussion on the scene layer.
- class Karana.Scene.CollisionScenePart#
Bases:
ScenePart,CollisionSceneNodeClass for objects with geometry and material in the scene
See Scene layer for more discussion on the scene layer.
- 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
See Scene layer for more discussion on the scene layer.
- static fromHex(hex_str: str) 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.
- Parameters:
hex_str – a 3 or 6 length hex string
- Returns:
the created Color
- static fromRGB(r: SupportsFloat | SupportsIndex, g: SupportsFloat | SupportsIndex, b: SupportsFloat | SupportsIndex) Color#
Create an opaque color from rgb components
- Parameters:
r – the red component between 0 and 1
g – the green component between 0 and 1
b – the blue component between 0 and 1
- Returns:
the created Color
- __eq__(other: Color) bool#
Equality operator.
- Parameters:
other – Another Color to compare with.
- Returns:
True if all components are equal.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [m, 1]]#
- classmethod to_yaml(representer, node)#
Class method used to represent Color in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a Color from yaml file data.
- class Karana.Scene.ConeGeometry(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex)#
Bases:
AbstractStaticGeometryConcrete cone geometry class
See Scene layer for more discussion on the scene layer.
- static create(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) ConeGeometry#
Create a new instance of ConeGeometry from radius and height.
- Parameters:
radius – radius of the capsule
height – height of the capsule’s middle section
- Returns:
A pointer to the newly created instance of BoxGeometry.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [2, 1]]#
- classmethod to_yaml(representer, node)#
Class method used to represent ConeGeometry in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a ConeGeometry from yaml file data.
- static to_json(o: ConeGeometry) dict[str, Any]#
Class method used to represent ConeGeometry in a json file.
- class Karana.Scene.Contact#
- property normal: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- property witness1: Karana.Math.Ktyping.Length[Karana.Math.Ktyping.Vec3]#
- property witness2: Karana.Math.Ktyping.Length[Karana.Math.Ktyping.Vec3]#
- class Karana.Scene.CylinderGeometry(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex)#
Bases:
AbstractStaticGeometryConcrete cylinder geometry class
See Scene layer for more discussion on the scene layer.
- static create(radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) CylinderGeometry#
Create a new instance of CylinderGeometry from radius and height.
- Parameters:
radius – radius of the capsule
height – height of the capsule’s middle section
- Returns:
A pointer to the newly created instance of BoxGeometry.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [2, 1]]#
- classmethod to_yaml(representer, node)#
Class method used to represent CylinderGeometry in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a CylinderGeometry from yaml file data.
- static to_json(o: CylinderGeometry) dict[str, Any]#
Class method used to represent CylinderGeometry in a json file.
- class Karana.Scene.DistanceInfo#
- static singleton() DistanceInfo#
- 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
See Scene layer for more discussion on the scene layer.
- addOverlayText(arg0: str, arg1: SupportsFloat | SupportsIndex, arg2: SupportsFloat | SupportsIndex, arg3: TextParameters) int#
- addOverlayText(message: str, x: SupportsFloat | SupportsIndex, y: SupportsFloat | SupportsIndex, align: Alignment = Alignment.LEFT, size: SupportsFloat | SupportsIndex = 0.05000000074505806, color: Color = ...) int
Add text in screen space
- Parameters:
message –
The content of the overlay text
x –
The horizontal position of the text between 0 and 1
y –
The vertical position of the text between 0 and 1
parameters –
Addition text parameters
- Returns:
Unique id to later update the text instance
- defaultCamera() GraphicalSceneCamera#
Get the automatically created default camera
- Returns:
The default camera
- removeOverlayText(arg0: SupportsInt | SupportsIndex) None#
Add text in screen space
- Parameters:
message –
The content of the overlay text
x –
The horizontal position of the text between 0 and 1
y –
The vertical position of the text between 0 and 1
parameters –
Addition text parameters
- Returns:
Unique id to later update the text instance
- renderToFile(arg0: os.PathLike | str | bytes) None#
Render the scene to a file
- Parameters:
filepath –
filename to render to
- setOverlayText(arg0: SupportsInt | SupportsIndex, arg1: str) None#
Add text in screen space
- Parameters:
message –
The content of the overlay text
x –
The horizontal position of the text between 0 and 1
y –
The vertical position of the text between 0 and 1
parameters –
Addition text parameters
- Returns:
Unique id to later update the text instance
- class Karana.Scene.GraphicalSceneCamera#
Bases:
GraphicalSceneNodeBase for objects with a transform i n the scene hierarchy
See Scene layer for more discussion on the scene layer.
- getProjection() PerspectiveProjection | OrthographicProjection#
Get the camera projection parameters
- Returns:
The camera projection parameters
- pointCameraAt(offset: Karana.Math.Ktyping.Vec3 | Karana.Math.Ktyping.Length[Karana.Math.Ktyping.Vec3], target: Karana.Math.Ktyping.Vec3 | Karana.Math.Ktyping.Length[Karana.Math.Ktyping.Vec3], up: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
Set the pose of the camera.
- Parameters:
offset – The position of the camera.
target – The position the camera will point at.
up – The up vector of the camera.
- setMask(mask: SupportsInt | SupportsIndex) None#
Set the bitmask for which layers should be visible.
- Parameters:
mask –
The layers bitmask
- setProjection(projection: PerspectiveProjection | OrthographicProjection) None#
Set the camera projection parameters
- Parameters:
proj – The camera projection parameters
- class Karana.Scene.GraphicalSceneNode#
Bases:
SceneNodeBase for objects with a transform i n the scene hierarchy
See Scene layer for more discussion on the scene layer.
- showAxes(size: SupportsFloat | SupportsIndex = 1.0) None#
Show axes to visualize the node’s position and orientation
- Parameters:
size –
Lengths of the axes (zero to remove the axes)
- trail(reference: GraphicalSceneNode = None, color: Color = ...) None#
Display a trail tracking the node’s motion over time.
- Parameters:
relative_to –
Another node to draw the trail relative to.
color –
The color of the Trail.
- class Karana.Scene.GraphicalScenePart#
Bases:
ScenePart,GraphicalSceneNodeClass for objects with geometry and material in the scene
See Scene layer for more discussion on the scene layer.
- class Karana.Scene.GrayscaleTexture#
Bases:
TextureTexture specialization for grayscale values
See Scene layer for more discussion on the scene layer.
- static lookupFilepath(grayscale_texture: GrayscaleTexture) pathlib.Path | None#
Get the filepath associated with the provided texture.
- Parameters:
grayscale_texture – The GrayscaleTexture to lookup the filepath for.
- Returns:
The filepath of the provided grayscale texture, or nullopt if no filepath is associated with the grayscale texture.
- 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.
- Parameters:
filename – The name of the file.
- Returns:
A ks_ptr to the GrayscaleTexture.
- classmethod to_yaml(representer, node)#
Class method used to represent GrayscaleTexture in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a GrayscaleTexture from yaml file data.
- static to_json(o: GrayscaleTexture) dict[str, Any]#
Class method used to represent GrayscaleTexture in a json file.
- class Karana.Scene.HeightFieldGeometry(size_x: SupportsFloat | SupportsIndex, size_y: SupportsFloat | SupportsIndex, heights: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, n]])#
Bases:
AbstractStaticGeometryNorthwest-origin 2D heightfield with fixed X/Y extents and sampled Z values.
The height matrix is indexed as (row, column). Grid sample (0, 0) is located at the local origin. Increasing the column index advances toward +X (east), while increasing the row index advances toward -Y (south). Consequently, the heightfield occupies [0, size_x] x [-size_y, 0] in its local frame.
See Scene layer for more discussion on the scene layer.
- static create(size_x: SupportsFloat | SupportsIndex, size_y: SupportsFloat | SupportsIndex, heights: Annotated[numpy.typing.ArrayLike, numpy.float32, [m, n]]) HeightFieldGeometry#
Create a northwest-origin heightfield.
- Parameters:
size_x – Extent in the positive local X direction; finite and positive.
size_y – Extent in the negative local Y direction; finite and positive.
heights – Height grid with at least two rows and columns. Entry (0, 0) is at local (0, 0); columns advance toward positive X and rows advance toward negative Y.
- Returns:
A pointer to the new heightfield geometry.
- computeMesh() StaticMeshGeometry#
- Returns:
A triangle mesh using the same northwest-origin local frame.
- fillHoles() HeightFieldGeometry#
Return a finite copy with every NaN hole filled symmetrically.
Missing samples are estimated in both row-first/column-second and column-first/row-second orders, then the estimates are averaged. Finite samples are preserved exactly. As long as one valid pixel exists this will return a valid heightfield.
- Returns:
A distinct finite heightfield with the same local extents.
- property heights: Annotated[numpy.typing.NDArray[numpy.float32], [m, n]]#
Height samples with rows toward -Y and columns toward +X.
- class Karana.Scene.ImportResult#
- property geometries: list[BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry]#
- property materials: list[PhysicalMaterial | PhongMaterial | WireframeMaterial]#
- property parts: list[ScenePartSpec]#
- class Karana.Scene.OrthographicProjection#
Info for an orthographic camera projection
- class Karana.Scene.PerspectiveProjection#
Info for a perspective camera projection
- class Karana.Scene.PhongMaterial(mat: PhongMaterialInfo)#
Bases:
Karana.Core.BaseWithVarsA standard Phong material
See Scene layer for more discussion on the scene layer.
- static create(mat: PhongMaterialInfo) PhongMaterial#
Create a PhongMaterial
- Parameters:
mat – the parameter struct
- Returns:
The created PhongMaterial
- __getstate__() PhongMaterialInfo#
- __setstate__(arg0: PhongMaterialInfo) None#
- property info: PhongMaterialInfo#
Parameters for the materials
- classmethod to_yaml(representer, node)#
Class method used to represent PhongMaterial in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a PhongMaterial from yaml file data.
- static to_json(o: PhongMaterial) dict[str, Any]#
Class method used to represent PhongMaterial in a json file.
- class Karana.Scene.PhongMaterialInfo#
Parameter struct for a PhongMaterial
- classmethod to_yaml(representer, node)#
Class method used to represent PhongMaterialInfo in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a PhongMaterialInfo from yaml file data.
- static to_json(o: PhongMaterialInfo) dict[str, Any]#
Class method used to represent PhongMaterialInfo in a json file.
- class Karana.Scene.PhysicalMaterial(mat: PhysicalMaterialInfo)#
Bases:
Karana.Core.BaseWithVarsA standard PBR material
See Scene layer for more discussion on the scene layer.
- static create(mat: PhysicalMaterialInfo) PhysicalMaterial#
Create a PhysicalMaterial
- Parameters:
mat – the parameter struct
- Returns:
The created PhysicalMaterial
- __getstate__() PhysicalMaterialInfo#
- __setstate__(arg0: PhysicalMaterialInfo) None#
- property info: PhysicalMaterialInfo#
Parameters for the materials
- classmethod to_yaml(representer, node)#
Class method used to represent PhysicalMaterial in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a PhysicalMaterial from yaml file data.
- static to_json(o: PhysicalMaterial) dict[str, Any]#
Class method used to represent PhysicalMaterial in a json file.
- class Karana.Scene.PhysicalMaterialInfo#
Parameter struct for a PhysicalMaterial
- __getstate__() tuple[Texture, Color, float, GrayscaleTexture, float, GrayscaleTexture, Texture, float]#
- property metalness_map: GrayscaleTexture#
grayscale metalness map
- property roughness_map: GrayscaleTexture#
grayscale roughness map
- classmethod to_yaml(representer, node)#
Class method used to represent PhysicalMaterialInfo in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a PhysicalMaterialInfo from yaml file data.
- static to_json(o: PhysicalMaterialInfo) dict[str, Any]#
Class method used to represent PhysicalMaterialInfo in a json file.
- class Karana.Scene.RoundFrustumGeometry(bottom_radius: SupportsFloat | SupportsIndex, top_radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex)#
Bases:
AbstractStaticGeometryConcrete round frustum geometry class
See Scene layer for more discussion on the scene layer.
- static create(bottom_radius: SupportsFloat | SupportsIndex, top_radius: SupportsFloat | SupportsIndex, height: SupportsFloat | SupportsIndex) RoundFrustumGeometry#
Create a new instance of CapsuleGeometry from radii and height.
- Parameters:
bottom_radius – radius of bottom face
top_radius – radius of top face
height – height of the frustum
- Returns:
A pointer to the newly created instance of RoundFrustumGeometry.
- __getstate__() Annotated[numpy.typing.NDArray[numpy.float32], [3, 1]]#
- classmethod to_yaml(representer, node)#
Class method used to represent RoundFrustumGeometry in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a RoundFrustumGeometry from yaml file data.
- static to_json(o: RoundFrustumGeometry) dict[str, Any]#
Class method used to represent RoundFrustumGeometry in a json file.
- class Karana.Scene.Scene#
Bases:
Karana.Core.BaseWithVarsBase container for a hierarchy of geometries
See Scene layer for more discussion on the scene layer.
- getSceneFileObjects(layers: SupportsInt | SupportsIndex = 4294967295) list[SceneFileObject]#
Get the list of scene file objects in the scene
- Parameters:
layers – Limit the returned list to file objects belonging to the specified layers.
- Returns:
The SceneFileObjects for this Scene.
- getSceneNodes() list[SceneNode]#
Get the list of scene nodes in the scene
- Returns:
The SceneNodes for this Scene.
- getSceneParts(layers: SupportsInt | SupportsIndex = 4294967295) list[ScenePart]#
Get the list of scene parts in the scene
- Parameters:
layers – Limit the returned list to parts belonging to the specified layers.
- Returns:
The SceneParts for this Scene.
- lookupSceneNode(arg0: str) SceneNode#
Return the list of scene nodes with the specified name A null pointer is returned if there is no scene node with the specified name. An exception is raised if there are multiple matching scene nodes.
- Parameters:
name – The name to lookup
- Returns:
List of SceneNodes with the specified name for this Scene.
- class Karana.Scene.SceneFileObject#
Bases:
SceneNodeClass for an opaque node with contents loaded from a file.
See Scene layer for more discussion on the scene layer.
- static getLayersString(arg0: SupportsInt | SupportsIndex) str#
Convert the layer value into a more readable string form
The conversion only uses the pre-defined and known layer values (eg. COLLISION etc)
- Parameters:
layer – the layer value
- Returns:
A string representation of the bitmask for which layers the part belongs to.
- getConvexity() int#
Get the is_convex flag set upon creation.
- Returns:
The value of the is_convex flag.
- getFilepath() pathlib.Path#
Get the file node’s filepath
- Returns:
The file node’s filepath
- getLayers() int#
Get which layers the part belongs to.
- Returns:
Bitmask for which layers the part belongs to.
- getVars() SceneFileObjectVars#
- class Karana.Scene.SceneFileObjectSpec(name: str = 'unnamed', filepath: os.PathLike | str | bytes = '', transform: Karana.Math.HomTran = ..., scale: SupportsFloat | SupportsIndex = 1.0, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False)#
-
- transform: Karana.Math.HomTran#
- __eq__(other: SceneFileObjectSpec) bool#
- property filepath: pathlib.Path#
- class Karana.Scene.SceneFileObjectVars#
Bases:
SceneNodeVars,Karana.Core.BaseVarsThe Vars for the SceneFileObject class.
- property filepath: Karana.Core.Var[str]#
The filepath of the SceneFileObject.
- property is_convex: Karana.Core.Var[bool]#
Hint for whether the file’s shapes are all convex
- property layers: Karana.Core.Var[int]#
The layers for the SceneFileObject.
- property layers_string: Karana.Core.Var[str]#
Readable string representation of the layers for the SceneFileObject
- class Karana.Scene.SceneNode#
Bases:
Karana.Core.BaseWithVarsBase for objects with a transform i n the scene hierarchy
See Scene layer for more discussion on the scene layer.
- attachTo(parent: SceneNode, maintain_world_transform: bool = False) None#
Attach to a parent node
- Parameters:
parent –
The parent node
maintain_world_sim_transform –
If true, update the node’s
relative transform so that its overall world transform doesn’t change after attaching it to the parent
- childrenNodes() list[SceneNode]#
Get the node’s children nodes
- Returns:
A list of the node’s children nodes
- detach(maintain_world_transform: bool = False) None#
Detach the node from its parent
- Parameters:
maintain_world_sim_transform –
If true, update the node’s
relative transform so that its overall world transform doesn’t change after detaching
- getManager() SceneNode#
Get a SceneNode managing this one
- Returns:
The managing scene node or nullptr
- getScale() float#
Get uniform scale of the node relative to its parent
- Returns:
The relative uniform scale
- getSimTransform() Karana.Math.SimTran#
Get similarity transform of the node relative to its parent
- Returns:
The similarity transform
- getVars() SceneNodeVars#
- getWorldSimTransform() Karana.Math.SimTran#
Get similarity transform of the node relative to the scene’s root
- Returns:
The similarity transform
- isSceneFileObject() bool#
Return true if this scene node is a scene file node
- Returns:
true if the node is a scene file node
- isScenePart() bool#
Return true if this scene node is a scene part
- Returns:
true if the node is a scene part
- setManager(manager: SceneNode) None#
Assign a managing scene node
- Parameters:
manager – The scene node managing this one (nullable)
- setScale(scale: SupportsFloat | SupportsIndex) None#
Set uniform of the node relative to its parent
- Parameters:
scale –
The relative uniform scale
- setSimTransform(scale: Karana.Math.SimTran) None#
Set similarity transform of the node relative to its parent
- Parameters:
transform –
The similarity transform
- setTranslation(translation: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]]) None#
Set position of the node relative to its parent
- Parameters:
translation –
The relative translation
- setUnitQuaternion(quaternion: Karana.Math.UnitQuaternion) None#
Set rotation of the node relative to its parent
- Parameters:
quaternion –
The relative rotation as a unit quaternion
- class Karana.Scene.SceneNodeVars#
Bases:
Karana.Core.BaseVars- property children_nodes: Karana.Core.Var[list[str]]#
The names of the children SceneNode instances.
- property parent_node: Karana.Core.Var[str]#
The name of the parent SceneNode.
- property scale: Karana.Core.Var[float]#
The local scale of the SceneNode.
- property transform: Karana.Core.Var[Karana.Math.HomTran]#
The local transform of the SceneNode.
- property world_scale: Karana.Core.Var[float]#
The world scale of the SceneNode.
- property world_transform: Karana.Core.Var[Karana.Math.HomTran]#
The world transform of the SceneNode.
- class Karana.Scene.ScenePart#
Bases:
SceneNodeClass for objects with geometry and material in the scene
See Scene layer for more discussion on the scene layer.
- static getLayersString(arg0: SupportsInt | SupportsIndex) str#
Convert the layer value into a more readable string form
The conversion only uses the pre-defined and known layer values (eg. COLLISION etc)
- Parameters:
layer – the layer value
- Returns:
A string representation of the bitmask for which layers the part belongs to.
- getGeometry() BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | 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.
- getLayers() int#
Get which layers the part belongs to.
- Returns:
Bitmask for which layers the part belongs to.
- getMaterial() PhysicalMaterial | PhongMaterial | WireframeMaterial#
Get the part’s material
- Returns:
The part’s material
- getVars() ScenePartVars#
- 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.
- Parameters:
scale –
The part’s intrinsic scale.
- setMaterial(arg0: PhysicalMaterial | PhongMaterial | WireframeMaterial) None#
Set the part’s material
- Parameters:
material –
The part’s new material.
- class Karana.Scene.ScenePartSpec(name: str = 'unnamed', geometry: BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry = None, material: PhysicalMaterial | PhongMaterial | WireframeMaterial = None, transform: Karana.Math.HomTran = ..., scale: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ..., layers: SupportsInt | SupportsIndex = 150994944)#
- geometry: BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry#
- material: PhysicalMaterial | PhongMaterial | WireframeMaterial#
- transform: Karana.Math.HomTran#
- property scale: Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- class Karana.Scene.ScenePartSpecVars#
Bases:
Karana.Core.BaseVarsThe Vars for the ScenePartSpec class.
- property convex: Karana.Core.Var[bool]#
The convexity flag
- property geometry: Karana.Core.Var[str]#
The geometry type
- property layers: Karana.Core.Var[int]#
The layers for the ScenePart.
- property layers_string: Karana.Core.Var[str]#
Readable string representation of the layers for the ScenePart
- property material: Karana.Core.Var[str]#
The material type
- property scale: Karana.Core.Var[Karana.Math.Ktyping.Vec3]#
The intrinsic (possibly non-uniform) scale for the geometry
- property transform: Karana.Core.Var[Karana.Math.HomTran]#
The transform
- class Karana.Scene.ScenePartVars#
Bases:
SceneNodeVars,Karana.Core.BaseVarsThe Vars for the ScenePart class.
- property aabb: Karana.Core.Var[Karana.Math.SpatialVector]#
The bounding box
- property color: Karana.Core.Var[str]#
The material color
- property convex: Karana.Core.Var[bool]#
The convexity flag
- property geometry: Karana.Core.Var[str]#
The geometry type
- property intrinsic_scale: Karana.Core.Var[Karana.Math.Ktyping.Vec3]#
The intrinsic (possibly non-uniform) scale for the geometry
- property layers: Karana.Core.Var[int]#
The layers for the ScenePart.
- property layers_string: Karana.Core.Var[str]#
Readable string representation of the layers for the ScenePart
- class Karana.Scene.SceneVars#
Bases:
Karana.Core.BaseVars- property num_nodes: Karana.Core.Var[int]#
The number of scene nodes
- class Karana.Scene.SphereGeometry(radius: SupportsFloat | SupportsIndex)#
Bases:
AbstractStaticGeometryConcrete sphere geometry class
See Scene layer for more discussion on the scene layer.
- static create(radius: SupportsFloat | SupportsIndex) SphereGeometry#
Create a new instance of SphereGeometry from a radius.
- Parameters:
radius – radius of the sphere
- Returns:
A pointer to the newly created instance of SphereGeometry.
- computeMesh() StaticMeshGeometry#
Convert to a triangular mesh
- Returns:
The converted mesh
- classmethod to_yaml(representer, node)#
Class method used to represent SphereGeometry in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a SphereGeometry from yaml file data.
- static to_json(o: SphereGeometry) dict[str, Any]#
Class method used to represent SphereGeometry in a json file.
- 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
See Scene layer for more discussion on the scene layer.
- static create(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]]) StaticMeshGeometry#
Create a new instance of CapsuleGeometry from radius and height.
- Parameters:
positions – matrix of vertex positions
faces – matrix of triangles as three vertex indices
normals – matrix of vertex normals
surface_map_coords – matrix of uv (texture) coords
- Returns:
A pointer to the newly created instance of StaticMeshGeometry.
- __getstate__() tuple[Annotated[numpy.typing.NDArray[numpy.float32], [m, 3]], Annotated[numpy.typing.NDArray[numpy.int32], [m, 3]], Annotated[numpy.typing.NDArray[numpy.float32], [m, 3]], Annotated[numpy.typing.NDArray[numpy.float32], [m, 2]], str, bool]#
- setConvexity(is_convex: bool = False) None#
Set whether this static mesh is convex; used by some client scenes.
- Parameters:
is_convex – Whether the mesh is convex
- property faces: Annotated[numpy.typing.NDArray[numpy.int32], [m, 3]]#
triangles consisting of three vertex indices
- 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
- classmethod to_yaml(representer, node)#
Class method used to represent StaticMeshGeometry in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a StaticMeshGeometry from yaml file data.
- static to_json(o: StaticMeshGeometry) dict[str, Any]#
Class method used to represent StaticMeshGeometry in a json file.
- class Karana.Scene.TextParameters#
Style parameters for text
- class Karana.Scene.Texture#
Bases:
Karana.Core.BaseWithVarsClass for a texture image
See Scene layer for more discussion on the scene layer.
- static create(name: str, data: Annotated[numpy.typing.ArrayLike, numpy.int8]) Texture#
Create a Texture instance.
- Parameters:
name – The Texture’s name.
data – The data for the texture.
- Returns:
A ks_ptr to the Texture.
- static lookupFilepath(texture: Texture) pathlib.Path | None#
Get the filepath associated with the provided texture.
- Parameters:
texture – The GrayscaleTexture to lookup the filepath for.
- Returns:
The filepath of the provided texture, or nullopt if no filepath is associated with the texture.
- 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.
- Parameters:
filename – The name of the file.
- Returns:
A ks_ptr to the Texture.
- 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.
- Parameters:
data – The data to set the Texture data to.
- writeToFile(filename: os.PathLike | str | bytes) None#
Write the texture to a file.
- Parameters:
filename – The name of the file to write to.
- classmethod to_yaml(representer, node)#
Class method used to represent Texture in a yaml file.
- classmethod from_yaml(_, node) Self#
Construct a Texture from yaml file data.
- class Karana.Scene.TransformUpdateScope(arg0: Scene)#
RAII wrapper for beginTransformUpdates and endTransformUpdates
- class Karana.Scene.WireframeMaterial(mat: WireframeMaterialInfo)#
Bases:
Karana.Core.BaseWithVarsA Wireframe material
See Scene layer for more discussion on the scene layer.
- static create(mat: WireframeMaterialInfo) WireframeMaterial#
Create a WireframeMaterial
- Parameters:
mat – the parameter struct
- Returns:
The created WireframeMaterial
- static to_json(o: WireframeMaterial) dict[str, Any]#
Class method used to represent WireframeMaterial in a json file.
- classmethod from_yaml(loader, node) Self#
Construct a WireframeMaterial from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent WireframeMaterial in a yaml file.
- __getstate__() WireframeMaterialInfo#
- __setstate__(arg0: WireframeMaterialInfo) None#
- property info: WireframeMaterialInfo#
Parameters for the materials
- class Karana.Scene.WireframeMaterialInfo#
Parameter struct for a WireframeMaterial
- static to_json(o: WireframeMaterialInfo) dict[str, Any]#
Class method used to represent WireframeMaterialInfo in a json file.
- classmethod from_json(d: dict[str, Any]) Self#
Construct a WireframeMaterialInfo from json file data.
- classmethod from_yaml(loader, node) Self#
Construct a WireframeMaterialInfo from yaml file data.
- classmethod to_yaml(representer, node)#
Class method used to represent WireframeMaterialInfo in a yaml file.
- Karana.Scene.defaultGeometry() BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry#
- Karana.Scene.defaultMaterial() PhysicalMaterial | PhongMaterial | WireframeMaterial#
- 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.
See Scene layer for more discussion on the scene layer.
- static create(name: str, root_frame: Karana.Frame.Frame) ProxyScene#
Create a ProxyScene
- Parameters:
name –
Name of the ProxyScene.
root_frame –
Default Frame to attach nodes to.
- Returns:
The created ProxyScene
- chaseFrame(frame: Karana.Frame.Frame, offset: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]], at_offset: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ..., up: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ...) None#
Position the default camera relative to a Frame
- Parameters:
frm – the Frame to chase around
offset – camera position relative to the Frame
at_offset – camera target relative to the Frame
up – camera up vector
- clientScenes() list[Karana.Scene.Scene]#
Get a list of all registered client Scenes
- Returns:
The list of client Scenes
- 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
- empty() bool#
Check if the ProxyScene has any nodes or parts
- Returns:
Whether the ProxyScene is empty
- getFileObjectsAttachedToFrame(frame: Karana.Frame.Frame, strict: bool, layers: SupportsInt | SupportsIndex = 4294967295) list[ProxySceneFileObject]#
Retrieve all ProxySceneFileObjects attached to the provided frame.
- Parameters:
frame –
The frame to retrieve parts from.
strict –
If true, then only get parts directly attached to the
provided frame. If false, then return all parts whose ancestor frame is the provided frame.
layers –
Limit to parts belonging to the specified layer.
- Returns:
A vector of ProxySceneFileObjects attached to the provided frame.
- getNodesAttachedToFrame(frame: Karana.Frame.Frame, strict: bool) list[ProxySceneNode]#
Retrieve all ProxySceneNodes attached to the provided frame.
- Parameters:
frame –
The frame to retrieve nodes from.
strict –
If true, then only get nodes directly attached to the
provided frame. If false, then return all nodes whose ancestor frame is the provided frame.
- Returns:
A vector of ProxySceneNodes attached to the provided frame.
- getPartsAttachedToFrame(frame: Karana.Frame.Frame, strict: bool, layers: SupportsInt | SupportsIndex = 4294967295) list[ProxyScenePart]#
Retrieve all ProxySceneParts attached to the provided frame.
- Parameters:
frame –
The frame to retrieve parts from.
strict –
If true, then only get parts directly attached to the
provided frame. If false, then return all parts whose ancestor frame is the provided frame.
layers –
Limit to parts belonging to the specified layer.
- Returns:
A vector of ProxySceneParts attached to the provided frame.
- getVars() ProxySceneVars#
- 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
- layers(client_scene: Karana.Scene.Scene) int#
Get the client’s layers value
- Parameters:
client_scene –
The client Scene
- Returns:
The layers value
- lookupProxyFromImpl(impl: Karana.Scene.SceneNode) ProxySceneNode#
Lookup the ProxySceneNode managing the given implementation
- Parameters:
impl –
The SceneNode in a client Scene
- Returns:
The corresponding ProxySceneNode
- originFrame(client_scene: Karana.Scene.Scene) Karana.Frame.Frame#
Get the Frame the client’s origin is centered at
- Parameters:
client_scene –
The client Scene
- Returns:
The origin Frame for the given client Scene
- registerClientScene(scene: Karana.Scene.Scene, origin_frame: Karana.Frame.Frame, layers: SupportsInt | SupportsIndex | None = None) None#
Register a client Scene to be managed
- Parameters:
scene –
The client Scene
origin_frame –
The Frame to center the client’s origin at
layers –
Bitmask for objects to implement
- rootFrame() Karana.Frame.Frame#
Get the root frame.
This is the frame that nodes are attached to by default.
- Returns:
The root Frame.
- setOriginFrame(client_scene: Karana.Scene.Scene, origin_frame: Karana.Frame.Frame) None#
Assign a new origin frame to the client
- Parameters:
client_scene – The client Scene
origin_frame – The origin Frame for the given client Scene
- showAxes(frame: Karana.Frame.Frame, size: SupportsFloat | SupportsIndex = 1.0) None#
Show the axes for a Frame
- Parameters:
frm – the Frame to show axes for
size – the size of the axes
- unregisterClientScene(arg0: Karana.Scene.Scene) None#
Unregister a client Scene to no longer be managed
- Parameters:
scene – The client Scene.
- update() None#
- update(arg0: Karana.Scene.Scene) None
Update all Frame-attached nodes’ transforms for all clients
- viewAroundFrame(frame: Karana.Frame.Frame, offset: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]], at_offset: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ..., up: Annotated[numpy.typing.ArrayLike, numpy.float64, [3, 1]] = ...) None#
Position the default camera relative to a Frame
- Parameters:
frm – the Frame to view around
offset – camera position relative to the Frame
at_offset – camera target relative to the Frame
up – camera up vector
- property update_callbacks: Karana.Core.VoidCallbackRegistry#
- setupGraphics(origin_frame: Karana.Frame.Frame, *, port: int = 29523, axes: float = 1.0, client_type: Literal['auto', 'electron', 'notebook', 'webbrowser', 'selenium'] | None = 'auto', wait_for_clients: int = 0, wait_for_clients_timeout: float = 0.0, print_connection_info: bool = True) tuple[Callable[[], None], Karana.Scene.WebScene]#
Easily set up graphics.
- Parameters:
origin_frame (Frame) – Frame to use as the world origin for the graphics scene.
port (int) – Port to bind the WebUI server to. Use 0 to request an arbitrary unused port. Defaults to 29523.
axes (float) – Length of axes visualization on root frame. Defaults to 1.0.
client_type (Literal["auto", "electron", "notebook", "webbrowser", "selenium"] | None) –
- Policy for launching a client.
”auto”: pick the best option for the environment and OS “electron”: always launch the electron client “notebook”: always open an IFrame in IPython “webbrowser”: always open a browser tab “selenium”: always open a chrome driver using selenium None: don’t automatically open a client
Defaults to “auto”.
wait_for_clients (int) – Number of client connections to wait for before continuing. Defaults to 0.
wait_for_clients_timeout (float) – Number of seconds to wait before raising an error if wait_for_clients is positive. Defaults to 0.
print_connection_info (bool) – If True, then print the connection info. Otherwise, do not print it.
- Returns:
A tuple containing the a cleanup callable and the graphics scene.
- Return type:
- class Karana.Scene.ProxySceneFileObject(name: str, scene: ProxyScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False)#
Bases:
Karana.Scene.SceneFileObject,ProxySceneNode- static create(name: str, scene: ProxyScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False) ProxySceneFileObject#
Create a ProxySceneFileObject.
- Parameters:
name – Name of the ProxySceneFileObject.
scene – The ProxyScene to add the ProxySceneFileObject to.
filepath – File to populate the node from.
layers – Layers to use for the ProxySceneFileObject.
is_convex – Whether the file’s geometries are all convex.
- Returns:
The new ProxyScene part.
- getVars() ProxySceneFileObjectVars#
- of(scene: Karana.Scene.Scene) Karana.Scene.SceneFileObject#
Get the implementation for a given client
- Parameters:
scene –
The client scene
- Returns:
The implementation of this node for the client
- class Karana.Scene.ProxySceneFileObjectVars#
Bases:
Karana.Scene.SceneFileObjectVars,Karana.Core.BaseVarsThe Vars for the ProxySceneFileObject class.
- property parent_frame: Karana.Core.Var[str]#
The parent frame name
- class Karana.Scene.ProxySceneNode(name: str, scene: ProxyScene)#
Bases:
Karana.Scene.SceneNode- ancestorFrame() Karana.Frame.Frame#
Get the unique Frame that an ancestor is attached to
- Returns:
The Frame that this node or an ancestor is attached to
- 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
- Parameters:
parent –
The Frame to attach to
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
- 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.
- Parameters:
name –
The name of the ProxySceneNode.
scene –
The ProxyScene to add the node to.
- Returns:
The created ProxySceneNode
- 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
- Parameters:
scene –
The client scene
- Returns:
The implementation of this node for the client
- setUnitQuaternion(arg0: Karana.Math.UnitQuaternion) None#
- update() None#
- update(arg0: Karana.Scene.Scene) None
Update the transform for all clients if attached to a Frame
- class Karana.Scene.ProxyScenePart(name: str, scene: ProxyScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial | Karana.Scene.WireframeMaterial, layers: SupportsInt | SupportsIndex = 150994944)#
- class Karana.Scene.ProxyScenePart(name: str, scene: ProxyScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944)
Bases:
Karana.Scene.ScenePart,ProxySceneNode- static create(name: str, scene: ProxyScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial | Karana.Scene.WireframeMaterial, layers: SupportsInt | SupportsIndex = 150994944) ProxyScenePart#
- static create(name: str, scene: ProxyScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944) ProxyScenePart
Create a ProxyScenePart.
- Parameters:
name –
Name of the ProxyScenePart.
scene –
The ProxyScene to add the ProxyScenePart to.
geometry –
Geometry of the ProxyScenePart.
material –
Material for the ProxyScenePart.
layers –
Layers to use for the ProxyScenePart.
- Returns:
The new ProxyScene part.
- static fromScenePartSpec(scene: ProxyScene, spec: Karana.Scene.ScenePartSpec) ProxyScenePart#
Create a ProxyScenePart from a ScenePartSpec.
- Parameters:
scene –
The ProxyScene to add the ProxyScenePart to.
spec – The spec to use to create the ProxyScenePart.
- Returns:
The new ProxyScene part.
- 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
- getVars() ProxyScenePartVars#
- 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
- Parameters:
scene –
The client scene
- Returns:
The implementation of this node for the client
- class Karana.Scene.ProxyScenePartVars#
Bases:
Karana.Scene.ScenePartVars,Karana.Core.BaseVarsThe Vars for the ProxyScenePart class.
- property parent_frame: Karana.Core.Var[str]#
The parent frame name
- class Karana.Scene.ProxySceneVars#
Bases:
Karana.Scene.SceneVars,Karana.Core.BaseVars- property root_frame: Karana.Core.Var[str]#
the root frame name
- class Karana.Scene.WebScene(name: str, server: Karana.WebUI.Server, default_lights: bool = True)#
Bases:
Karana.Scene.GraphicalSceneGraphicalScene implementation for web-based graphics
See Scene layer for more discussion on the scene layer.
- static create(name: str, server: Karana.WebUI.Server, default_lights: bool = True) WebScene#
Create a WebScene
- Parameters:
name – Name for the WebScene
server – Server to communicate with frontends
default_lights – Whether to automatically create opposing lights
- Returns:
The created WebScene
- defaultCamera() Karana.Scene.GraphicalSceneCamera#
Get the default camera
- Returns:
The camera
- renderToFile(filepath: os.PathLike | str | bytes) None#
- server() Karana.WebUI.Server#
Get the server used by WebScene
- Returns:
The server used to communicate with frontends
- setOnHover(on_pick: collections.abc.Callable[[WebScenePart | None], None]) None#
Set a callback for when a part is hovered over
- Parameters:
on_hover – The callback to call with the part’s id
- setOnPick(on_pick: collections.abc.Callable[[WebScenePart | None], None]) None#
Set a callback for when a part is clicked on
- Parameters:
on_pick – The callback to call with the part’s id
- class Karana.Scene.WebSceneAmbientLight(name: str, scene: WebScene, color: Karana.Scene.Color = ..., intensity: SupportsFloat | SupportsIndex = 1.0)#
Bases:
WebSceneNode- static create(name: str, scene: WebScene, color: Karana.Scene.Color = ..., intensity: SupportsFloat | SupportsIndex = 1.0) WebSceneAmbientLight#
Create a new WebSceneAmbientLight
- Parameters:
name – Name for the WebSceneAmbientLight
scene – WebScene to add the camera to.
color – Color of the light.
intensity – Intensity of the light.
- Returns:
A pointer to the new light.
- getColor() Karana.Scene.Color#
Get the light color
- Returns:
The light color
- setColor(color: Karana.Scene.Color) None#
Set the light color
- Parameters:
color – The light color
- class Karana.Scene.WebSceneDirectionalLight(name: str, scene: WebScene, color: Karana.Scene.Color = ..., intensity: SupportsFloat | SupportsIndex = 1.0)#
Bases:
WebSceneNode- static create(name: str, scene: WebScene, color: Karana.Scene.Color = ..., intensity: SupportsFloat | SupportsIndex = 1.0) WebSceneDirectionalLight#
Create a new WebSceneDirectionalLight
- Parameters:
name – Name for the WebSceneDirectionalLight
scene – WebScene to add the camera to.
color – Color of the light.
intensity – Intensity of the light.
- Returns:
A pointer to the new light.
- getColor() Karana.Scene.Color#
Get the light color
- Returns:
The light color
- setColor(color: Karana.Scene.Color) None#
Set the light color
- Parameters:
color – The light color
- setIntensity(intensity: SupportsFloat | SupportsIndex) None#
Set the light intensity
- Parameters:
intensity – The light intensity
- setShadows(intensity: SupportsFloat | SupportsIndex = 1.0, pixels: SupportsInt | SupportsIndex = 2048, radius: SupportsFloat | SupportsIndex = 10.0, near: SupportsFloat | SupportsIndex = 0.001, far: SupportsFloat | SupportsIndex = 100000000000.0) None#
Enable and configure shadow casting for this light
- Parameters:
intensity – Shadow intensity in the range [0, 1]
pixels – Pixel dimensions of the square shadow map
radius – Radius of shadow camera frustum cross-section
near – Minimum distance to cast shadows
far – Maximum distance to cast shadows
- setTarget(target: WebSceneNode) None#
Set a target node to point the light at
- Parameters:
target – The target node
- class Karana.Scene.WebSceneFileObject(name: str, scene: WebScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False)#
Bases:
Karana.Scene.SceneFileObject,WebSceneNode- static create(name: str, scene: WebScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False) WebSceneFileObject#
Create a WebSceneFileObject.
- Parameters:
name – Name of the WebSceneFileObject.
scene – The GraphicalScene to add the WebSceneFileObject to.
filepath – Filepath to populate the node from.
layers – Layers to use for the WebSceneFileObject.
is_convex – Whether the file’s shapes are all convex.
- Returns:
The new WebScene file node.
- class Karana.Scene.WebSceneNode(name: str, scene: WebScene)#
Bases:
Karana.Scene.GraphicalSceneNode- static create(name: str, scene: WebScene) WebSceneNode#
Create a WebSceneNode.
- Parameters:
name –
Name of the node.
scene –
The WebScene to add the node to.
- Returns:
The created WebSceneNode.
- class Karana.Scene.WebScenePart(name: str, scene: WebScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial | Karana.Scene.WireframeMaterial, layers: SupportsInt | SupportsIndex = 150994944)#
- class Karana.Scene.WebScenePart(name: str, scene: WebScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944)
Bases:
Karana.Scene.GraphicalScenePart,WebSceneNode- static create(name: str, scene: WebScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial | Karana.Scene.WireframeMaterial, layers: SupportsInt | SupportsIndex = 150994944) WebScenePart#
- static create(name: str, scene: WebScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944) WebScenePart
Create a WebScenePart.
- Parameters:
name –
Name of the WebScenePart.
scene –
The GraphicalScene to add the WebScenePart to.
geometry –
Geometry of the WebScenePart.
material –
Material for the WebScenePart.
layers –
Layers to use for the WebScenePart.
- Returns:
The new WebScene part.
- getIntrinsicScale() Annotated[numpy.typing.NDArray[numpy.float64], [3, 1]]#
- class Karana.Scene.WebScenePointLight(name: str, scene: WebScene, color: Karana.Scene.Color = ..., intensity: SupportsFloat | SupportsIndex = 1.0)#
Bases:
WebSceneNode- static create(name: str, scene: WebScene, color: Karana.Scene.Color = ..., intensity: SupportsFloat | SupportsIndex = 1.0) WebScenePointLight#
Create a new WebScenePointLight
- Parameters:
name – Name for the WebScenePointLight
scene – WebScene to add the camera to.
color – Color of the light.
intensity – Intensity of the light.
- Returns:
A pointer to the new light.
- getColor() Karana.Scene.Color#
Get the light color
- Returns:
The light color
- setColor(color: Karana.Scene.Color) None#
Set the light color
- Parameters:
color – The light color
- setIntensity(intensity: SupportsFloat | SupportsIndex) None#
Set the light intensity
- Parameters:
intensity – The light intensity
- setShadows(intensity: SupportsFloat | SupportsIndex = 1.0, pixels: SupportsInt | SupportsIndex = 2048, near: SupportsFloat | SupportsIndex = 0.001, far: SupportsFloat | SupportsIndex = 100000000000.0) None#
Enable and configure shadow casting for this light
- Parameters:
intensity – Shadow intensity in the range [0, 1]
pixels – Pixel dimensions of the square shadow map
near – Minimum distance to cast shadows
far – Maximum distance to cast shadows
- class Karana.Scene.WebSceneSpotLight(name: str, scene: WebScene, color: Karana.Scene.Color = ..., intensity: SupportsFloat | SupportsIndex = 1.0, angle: SupportsFloat | SupportsIndex = 1.0471975511965976)#
Bases:
WebSceneNode- static create(name: str, scene: WebScene, color: Karana.Scene.Color = ..., intensity: SupportsFloat | SupportsIndex = 1.0, angle: SupportsFloat | SupportsIndex = 1.0471975511965976) WebSceneSpotLight#
Create a new WebSceneSpotLight
- Parameters:
name – Name for the WebSceneSpotLight
scene – WebScene to add the camera to.
color – Color of the light.
intensity – Intensity of the light.
angle – Angle of cone from center line in radians.
- Returns:
A pointer to the new light.
- getColor() Karana.Scene.Color#
Get the light color
- Returns:
The light color
- setAngle(angle: SupportsFloat | SupportsIndex) None#
Set the cone angle from center line
- Parameters:
angle – The angle
- setColor(color: Karana.Scene.Color) None#
Set the light color
- Parameters:
color – The light color
- setIntensity(intensity: SupportsFloat | SupportsIndex) None#
Set the light intensity
- Parameters:
intensity – The light intensity
- setTarget(target: WebSceneNode) None#
Set a target node to point the light at
- Parameters:
target – The target node
- class Karana.Scene.CoalScene(name: str)#
Bases:
Karana.Scene.CollisionSceneCollisionScene implementation using the COAL library
See Scene layer for more discussion on the scene layer.
- static create(name: str) CoalScene#
Create a CoalScene
- Parameters:
name –
Name for the CoalScene
- Returns:
The created CoalScene
- getContactPatchTolerance() float#
Get the distance tolerance used to choose contact force locations.
- Returns:
Positive contact-patch tolerance in meters.
- getGJKEPATolerance() float#
Get the tolerance used by the GJK and EPA narrowphase solvers.
- Returns:
The shared GJK/EPA tolerance.
- getLocalPlaneApproximationSupport() float#
Get the scaling factor for the ellipsoid used to fit the local terrain plane.
- Returns:
Positive, finite scaling factor; defaults to 1.
- getMaxNumContacts() int#
Get the maximum number of contact points that we track between any two scene parts
- Returns:
size_t
- getUseContactPatchRefinement() bool#
Return whether contact-patch refinement is enabled.
- Returns:
True when ordinary contacts use COAL contact-patch centers.
- getUseLocalPlaneApproximation() bool#
Return whether terrain contacts use local plane approximation.
- Returns:
True when approximation is enabled; false by default.
- setContactPatchTolerance(tolerance: SupportsFloat | SupportsIndex) None#
Set the distance tolerance used to choose contact force locations.
This setting controls which nearby surface points are included when choosing where the contact force acts. It is separate from the collision solver’s accuracy setting. Smaller values can turn a nearly flat contact area into an edge or point contact. This does not affect local plane approximation. The default patch tolerance is 1e-3 meters.
- Parameters:
tolerance – Positive, finite patch tolerance in meters.
- setGJKEPATolerance(tolerance: SupportsFloat | SupportsIndex) None#
Set the tolerance used by the GJK and EPA narrowphase solvers.
Also broadcasts this value to every existing CoalScenePart.
- Parameters:
tolerance – Positive, finite solver tolerance.
- setLocalPlaneApproximationSupport(support: SupportsFloat | SupportsIndex) None#
Set the ellipsoidal footprint used to fit the local terrain plane.
A value of 1 wraps an ellipsoid around the collider’s local bounding box. The ellipsoid turns with the collider and projects straight down onto the terrain. Larger values average ground over a wider area. At terrain edges, the fit uses the available ground within that footprint. Numerically degenerate projections use ordinary collision detection rather than an artificial width. This changes the fitted surface, not the collision geometry’s dimensions. Changes apply to existing and future parts without enabling approximation.
- Parameters:
support – Positive, finite scaling factor with no upper bound.
- Raises:
std::invalid_argument – If support is nonpositive or nonfinite.
- setMaxNumContacts(max_contacts: SupportsInt | SupportsIndex) None#
Set the maximum number of contact points that we track between any two scene parts.
Also broadcasts this information to every existing CoalScenePart
- Parameters:
max_contacts – New maximum count
- setUseContactPatchRefinement(enabled: bool) None#
Enable or disable contact-patch refinement.
When enabled, ordinary contacts place the force at the center of the contact area reported by COAL. When disabled, ordinary contacts use COAL’s contact points directly. Local plane approximation ignores this setting for height fields.
- Parameters:
enabled – Whether contact-patch refinement is enabled.
- setUseLocalPlaneApproximation(enabled: bool) None#
Enable or disable local plane approximation for terrain contacts.
Approximation smooths terrain (height field) peaks and valleys beneath supported convex objects. Non-convex meshes fall back to ordinary collision detection. This flag affects all current and future height field scene parts for this scene.
- Parameters:
enabled – Whether to enable approximation.
- toDS() Karana.Scene.CoalScene_types.CoalSceneDS#
Create a CoalSceneDS from this CoalScene model.
- Returns:
CoalSceneDS
A CoalSceneDS instance with values set to match this model.
- class Karana.Scene.CoalSceneFileObject(name: str, scene: CoalScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False)#
Bases:
Karana.Scene.SceneFileObject,CoalSceneNodeSceneFileObject implementation for CoalScene
See Scene layer for more discussion on the scene layer.
- static create(name: str, scene: CoalScene, filepath: os.PathLike | str | bytes, layers: SupportsInt | SupportsIndex = 150994944, is_convex: bool = False) CoalSceneFileObject#
Create a CoalSceneFileObject.
- Parameters:
name – Name of the CoalSceneFileObject.
scene – The GraphicalScene to add the CoalSceneFileObject to.
filepath – Filepath to populate the node from.
layers – Layers to use for the CoalSceneFileObject.
is_convex – Whether the file’s shapes are all convex.
- Returns:
The new CoalScene file node.
- class Karana.Scene.CoalSceneNode(name: str, scene: CoalScene)#
Bases:
Karana.Scene.CollisionSceneNodeCollisionSceneNode implementation for CoalScene
See Scene layer for more discussion on the scene layer.
- static create(name: str, scene: CoalScene) CoalSceneNode#
Create a CoalSceneNode.
- Parameters:
name –
The name of the CoalSceneNode.
scene –
The CoalScene to add the node to.
- Returns:
The created CoalSceneNode.
- class Karana.Scene.CoalScenePart(name: str, scene: CoalScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial | Karana.Scene.WireframeMaterial, layers: SupportsInt | SupportsIndex = 150994944)#
- class Karana.Scene.CoalScenePart(name: str, scene: CoalScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944)
Bases:
CoalSceneNode,Karana.Scene.CollisionScenePartCollisionScenePart implementation for CoalScene
See Scene layer for more discussion on the scene layer.
- static create(name: str, scene: CoalScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, material: Karana.Scene.PhysicalMaterial | Karana.Scene.PhongMaterial | Karana.Scene.WireframeMaterial, layers: SupportsInt | SupportsIndex = 150994944) CoalScenePart#
- static create(name: str, scene: CoalScene, geometry: Karana.Scene.BoxGeometry | Karana.Scene.CapsuleGeometry | Karana.Scene.ConeGeometry | Karana.Scene.CylinderGeometry | Karana.Scene.RoundFrustumGeometry | Karana.Scene.SphereGeometry | Karana.Scene.HeightFieldGeometry | Karana.Scene.StaticMeshGeometry | Karana.Scene.AbstractStaticGeometry, layers: SupportsInt | SupportsIndex = 150994944) CoalScenePart
Create a CoalScenePart.
- Parameters:
name –
Name of the CoalScenePart.
scene –
The GraphicalScene to add the CoalScenePart to.
geometry –
Geometry of the CoalScenePart.
material –
Material for the CoalScenePart.
layers –
Layers to use for the CoalScenePart.
- Returns:
The new CoalScene part.