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 |
|
Color class |
|
Concrete cone geometry class |
|
Concrete cylinder geometry class |
|
Scene with an added graphics-specific interface |
|
Texture specialization for grayscale values |
|
Center-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 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 |
|
Functions#
|
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#
- Karana.Scene.getConvexDecomposition(geom: StaticMeshGeometry, coacd_args: dict = {}, 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.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
See Scene layer for more discussion on the scene layer.
- static fromHex(hex_str: str, alpha: SupportsFloat | SupportsIndex = 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.
- Parameters:
hex_str – a 3 or 6 length hex string
alpha – the opacity factor between 0 and 1
- 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
- static fromRGBA(r: SupportsFloat | SupportsIndex, g: SupportsFloat | SupportsIndex, b: SupportsFloat | SupportsIndex, alpha: SupportsFloat | SupportsIndex) Color#
Create a color from rgb components and opacity
- 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
alpha – the opacity factor 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], [4, 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 penetration: Karana.Math.Ktyping.Length#
- property witness1: Karana.Math.Ktyping.Length3#
- property witness2: Karana.Math.Ktyping.Length3#
- 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:
GraphicalSceneNode- getProjection() PerspectiveProjection | OrthographicProjection#
Get the camera projection parameters
- Returns:
The camera projection parameters
- pointCameraAt(offset: numpy.typing.ArrayLike | Karana.Math.Ktyping.Length3, target: numpy.typing.ArrayLike | Karana.Math.Ktyping.Length3, 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:
SceneNode- 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,GraphicalSceneNode
- 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:
AbstractStaticGeometryCenter-origin 2D heightfield with fixed X/Y extents and sampled Z values.
The local origin is at the center of the X/Y extent. Grid sample (0, 0) is located at (size_x / 2, size_y / 2). Increasing the column index advances toward -X; increasing the row index advances toward -Y. Consequently, the heightfield occupies [-size_x / 2, size_x / 2] x [-size_y / 2, size_y / 2] in its local frame. This convention matches the centered local bounds of coal::HeightField.
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 center-origin heightfield.
- Parameters:
size_x – Side length in the X direction; finite and positive.
size_y – Side length in the Y direction; finite and positive.
heights – Height grid with at least two rows and columns. Entry (0, 0) is at local (+size_x / 2, +size_y / 2); columns advance toward -X and rows advance toward -Y.
- Returns:
A pointer to the new heightfield geometry.
- computeMesh() StaticMeshGeometry#
- Returns:
A triangle mesh using the same centered local frame.
- property heights: Annotated[numpy.typing.NDArray[numpy.float32], [m, n]]#
Height samples over the centered X/Y extent.
- class Karana.Scene.ImportResult#
- property geometries: list[BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | StaticMeshGeometry | AbstractStaticGeometry]#
- property materials: list[PhysicalMaterial | PhongMaterial]#
- 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]#
- 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.
- getSceneNodes() list[SceneNode]#
Get the list of scene nodes in the scene
- Returns:
The SceneNodes 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#
- property filepath: pathlib.Path#
- class Karana.Scene.SceneFileObjectVars#
Bases:
SceneNodeVars,Karana.Core.BaseVarsThe Vars for the SceneFileObject class.
- property filepath: Karana.Core.VarString#
The filepath of the SceneFileObject.
- property is_convex: Karana.Core.VarBool#
Hint for whether the file’s shapes are all convex
- property layers: Karana.Core.VarInt#
The layers for the SceneFileObject.
- property layers_string: Karana.Core.VarString#
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.VarVecString#
The names of the children SceneNode instances.
- property parent_node: Karana.Core.VarString#
The name of the parent SceneNode.
- property scale: Karana.Core.VarDouble#
The local scale of the SceneNode.
- property transform: Karana.Core.VarHomTran#
The local transform of the SceneNode.
- property world_scale: Karana.Core.VarDouble#
The world scale of the SceneNode.
- property world_transform: Karana.Core.VarHomTran#
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#
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) 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 = 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#
- 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.VarBool#
The convexity flag
- property geometry: Karana.Core.VarString#
The geometry type
- property layers: Karana.Core.VarInt#
The layers for the ScenePart.
- property layers_string: Karana.Core.VarString#
Readable string representation of the layers for the ScenePart
- property material: Karana.Core.VarString#
The material type
- property scale: Karana.Core.VarVec3#
The intrinsic (possibly non-uniform) scale for the geometry
- property transform: Karana.Core.VarHomTran#
The transform
- class Karana.Scene.ScenePartVars#
Bases:
SceneNodeVars,Karana.Core.BaseVarsThe Vars for the ScenePart class.
- property aabb: Karana.Core.VarSpatialVector#
The bounding box
- property convex: Karana.Core.VarBool#
The convexity flag
- property geometry: Karana.Core.VarString#
The geometry type
- property intrinsic_scale: Karana.Core.VarVec3#
The intrinsic (possibly non-uniform) scale for the geometry
- property layers: Karana.Core.VarInt#
The layers for the ScenePart.
- property layers_string: Karana.Core.VarString#
Readable string representation of the layers for the ScenePart
- class Karana.Scene.SceneVars#
Bases:
Karana.Core.BaseVars- property num_nodes: Karana.Core.VarInt#
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
- Karana.Scene.defaultGeometry() BoxGeometry | CapsuleGeometry | ConeGeometry | CylinderGeometry | RoundFrustumGeometry | SphereGeometry | HeightFieldGeometry | 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.
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.
- 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) 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.
- 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.VarString#
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#
- 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, 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, 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.VarString#
The parent frame name
- class Karana.Scene.ProxySceneVars#
Bases:
Karana.Scene.SceneVars,Karana.Core.BaseVars- property root_frame: Karana.Core.VarString#
the root frame name
- class Karana.Scene.WebScene(name: str, server: Karana.WebUI.Server)#
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) WebScene#
Create a WebScene
- Parameters:
name –
Name for the WebScene
server –
Server to communicate with frontends
- 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.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, 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, 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.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
- getGJKEPATolerance() float#
Get the tolerance used by the GJK and EPA narrowphase solvers.
- Returns:
The shared GJK/EPA tolerance.
- getMaxNumContacts() int#
Get the maximum number of contact points that we track between any two scene parts
- Returns:
size_t
- 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.
- 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
- 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,CoalSceneNode- 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.CollisionSceneNode- 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, 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.CollisionScenePart- 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, 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.