TheMatrix.Core

Math.Geometry.Ray3D

A Vector-like construct

Math.LinearAlgebra.MatrixHelper.GenerateViewMatrix()

Generate from orientation

Math.LinearAlgebra.MatrixHelper.GenerateViewMatrixLookingAt()

Generate by "looking at"

Math.LinearAlgebra.MatrixHelper.GenerateViewMatrix()

Notice this is merely TRS from view space to world space, it doesn't contain any perspectives

Math.LinearAlgebra.ObjectHelper.CameraOrientationToVectors()

Remarks

Assume The Matrix coordinate system, and camera by default looks towards +X and sits with +Z as up; Rotation is defined by left-hand

Math.LinearAlgebra.Rotation3D

Conventionally in degrees rather than in radians; Defined using left hand (counterclock-wise around the axis)

Math.LinearAlgebra.Polar3D

In degrees

Algorithms.BooleanMesh

Provides boolean operations on meshes (assume triangulated)

Algorithms.Heightmap

Outputs triangle mesh data of a height map terrain Reference implementation: https://developer.playcanvas.com/en/tutorials/terrain-generation/ Zora RFC: 075

Remarks

TODO: - [ ] Add unit test for basic editing functions - [ ] Consolidate noise generation with https://github.com/cmsommer/DotnetNoise?tab=readme-ov-file; Create our own dedicated noise class to be shared.

Algorithms.Heightmap.Width

Gets the width of the heightmap (number of columns).

Algorithms.Heightmap.Height

Gets the height of the heightmap (number of rows).

Algorithms.Heightmap.#ctor()

Initializes a new instance of the Heightmap class with the specified dimensions.

Parameters

NameDescriptionDefault
width The width (number of columns) of the heightmap.
height The height (number of rows) of the heightmap.

Algorithms.Heightmap.#ctor()

Initializes a new instance of the Heightmap class with the specified data.

Parameters

NameDescriptionDefault
initialData A jagged array of doubles representing the heightmap data.

Algorithms.Heightmap.Item()

Gets or sets the height value at the specified (x, y) coordinate.

Parameters

NameDescriptionDefault
x The x-coordinate (column index).
y The y-coordinate (row index).

Returns

The height value at the specified coordinate.

Algorithms.Heightmap.GeneratePerlinNoiseTerrain()

Generates terrain using Perlin noise.

Parameters

NameDescriptionDefault
scale Scale of the noise.
offsetX X offset for the noise.
offsetY Y offset for the noise.

Algorithms.Heightmap.GenerateFractalNoiseTerrain()

Generates terrain using Fractal Brownian Motion (fBm).

Parameters

NameDescriptionDefault
scale Scale of the noise.
octaves Number of octaves.
persistence Controls the amplitude of each octave.
lacunarity Controls the frequency of each octave.
offsetX X offset for the noise.
offsetY Y offset for the noise.

Algorithms.Heightmap.GenerateRidgedMultifractalTerrain()

Generates terrain using Ridged Multifractal noise.

Parameters

NameDescriptionDefault
scale Scale of the noise.
octaves Number of octaves.
offsetX X offset for the noise.
offsetY Y offset for the noise.

Algorithms.Heightmap.GetValue()

Gets the height value at the specified (x, y) coordinate.

Parameters

NameDescriptionDefault
x The x-coordinate (column index).
y The y-coordinate (row index).

Returns

The height value at the specified coordinate.

Algorithms.Heightmap.SetValue()

Sets the height value at the specified (x, y) coordinate.

Parameters

NameDescriptionDefault
x The x-coordinate (column index).
y The y-coordinate (row index).
value The height value to set.

Algorithms.Heightmap.GetGradient()

Gets the gradient (partial derivatives) at the specified (x, y) coordinate.

Parameters

NameDescriptionDefault
x The x-coordinate (column index).
y The y-coordinate (row index).

Returns

A tuple containing the partial derivatives (dx, dy).

Algorithms.Heightmap.GetAngleDegree()

Calculates the slope angle in degrees based on the gradient at a given point.

Parameters

NameDescriptionDefault
x The x-coordinate (column index).
y The y-coordinate (row index).

Returns

The slope angle in degrees

Algorithms.Heightmap.GetNormal()

Gets the normal vector at the specified (x, y) coordinate.

Parameters

NameDescriptionDefault
x The x-coordinate (column index).
y The y-coordinate (row index).

Returns

A tuple representing the normalized normal vector (nx, ny, nz).

Algorithms.Heightmap.GetNormal()

Computes the normal vector of a triangle defined by three 3D points. Points should be specified in counter-clockwise order to ensure the normal points outward (right-hand rule).

Returns

A normalized Vector3D representing the normal of the plane defined by the three points.

Algorithms.Heightmap.GetMinHeight

Gets the minimum height value in the heightmap.

Returns

The minimum height value.

Algorithms.Heightmap.GetMaxHeight

Gets the maximum height value in the heightmap.

Returns

The maximum height value.

Algorithms.Heightmap.GetAverageHeight

Gets the average height value of the heightmap.

Returns

The average height value.

Algorithms.Heightmap.Smooth

Smooths the heightmap using a simple averaging filter.

Algorithms.Heightmap.Erode()

Applies thermal erosion to the entire heightmap.

Parameters

NameDescriptionDefault
iterations The number of erosion iterations to perform.
talusAngle The maximum stable slope (in height units).
erosionFactor Controls how much material moves per iteration (0 to 1).

Algorithms.Heightmap.ScaleHeights()

Scales the heightmap vertically by the specified factor.

Parameters

NameDescriptionDefault
scale The scale factor to apply.

Algorithms.Heightmap.Add()

Adds another heightmap to this heightmap, element-wise.

Parameters

NameDescriptionDefault
other The other heightmap to add.

Algorithms.Heightmap.Crop()

Crops the heightmap to the specified rectangular region.

Parameters

NameDescriptionDefault
startX The starting x-coordinate (column index).
startY The starting y-coordinate (row index).
cropWidth The width of the cropped region.
cropHeight The height of the cropped region.

Returns

A new Heightmap instance representing the cropped region.

Algorithms.Heightmap.Resize()

Resizes the heightmap to the specified dimensions using nearest neighbor scaling.

Parameters

NameDescriptionDefault
newWidth The new width (number of columns).
newHeight The new height (number of rows).

Algorithms.Heightmap.Apply()

Applies a custom transformation function to each height value in the heightmap.

Parameters

NameDescriptionDefault
transform The function to apply to each height value.

Algorithms.Heightmap.RotateCW

Rotates the heightmap data 90 degrees clockwise.

Algorithms.Heightmap.RotateCCW

Rotates the heightmap data 90 degrees counterclockwise.

Algorithms.Heightmap.ApplyMasks()

Applies a series of HeightmapMasks to the Heightmap using a specified modification function.

Parameters

NameDescriptionDefault
masks Array of HeightmapMasks to apply.
modification Function that modifies the height based on the mask value and coordinates.

Algorithms.Heightmap.GenerateBiomeTexture

Generates a biome texture image based on the heightmap data.

Returns

An Image representing the biome texture.

Algorithms.Heightmap.GetBiomeColor()

Determines the biome color based on the normalized height.

Algorithms.Heightmap.SmoothBrush()

Applies a smoothing operation within a brush area.

Parameters

NameDescriptionDefault
centerX The x-coordinate of the brush center.
centerY The y-coordinate of the brush center.
radius The radius of the brush.
falloff The fall-off parameter (0 to 1).
brushShape The shape of the brush ("circle" or "rectangle").

Algorithms.Heightmap.FlattenBrush()

Flattens the terrain within a brush area to a target height.

Parameters

NameDescriptionDefault
centerX The x-coordinate of the brush center.
centerY The y-coordinate of the brush center.
radius The radius of the brush.
falloff The fall-off parameter (0 to 1).
targetHeight The target height to flatten to.
brushShape The shape of the brush ("circle" or "rectangle").

Algorithms.Heightmap.RaiseLowerBrush()

Raises or lowers the terrain within a brush area.

Parameters

NameDescriptionDefault
centerX The x-coordinate of the brush center.
centerY The y-coordinate of the brush center.
radius The radius of the brush.
falloff The fall-off parameter (0 to 1).
deltaHeight The amount to raise or lower the height.
brushShape The shape of the brush ("circle" or "rectangle").

Algorithms.Heightmap.ErodeBrush()

Simple erosion

Algorithms.Heightmap.ErodeBrush()

Applies thermal erosion within a brush area.

Parameters

NameDescriptionDefault
centerX The x-coordinate of the brush center.
centerY The y-coordinate of the brush center.
radius The radius of the brush.
falloff The fall-off parameter (0 to 1).
iterations The number of erosion iterations to perform.
talusAngle The maximum stable slope (in height units).
erosionFactor Controls how much material moves per iteration (0 to 1).
brushShape The shape of the brush ("circle" or "rectangle").

Algorithms.Heightmap.ApplyBrush()

Generic method to apply a brush operation with fall-off.

Parameters

NameDescriptionDefault
operation The operation to apply at each point.
centerX The x-coordinate of the brush center.
centerY The y-coordinate of the brush center.
radius The radius of the brush.
falloff The fall-off parameter (0 to 1).
brushShape The shape of the brush ("circle" or "rectangle").

Algorithms.Heightmap.ExportObj()

Exports the heightmap to an OBJ 3D file.

Parameters

NameDescriptionDefault
filePath The path to the OBJ file to be created.
useQuads If true, exports using quads; otherwise, uses triangles.
vertexMode If true, consider each vertex in the data array as center of each pixel, we need to create new vertices based on the center.

Algorithms.Heightmap.Clone

Clones the heightmap, creating a deep copy.

Returns

A new Heightmap instance with the same data.

Algorithms.Heightmap.InterpolateHeight()

Interpolates the height value at the specified (x, y) coordinate using bilinear interpolation.

Parameters

NameDescriptionDefault
x The x-coordinate (can be fractional).
y The y-coordinate (can be fractional).

Returns

The interpolated height value.

Algorithms.Heightmap.InterpolateHeightSafe()

Safely interpolates the height value at the specified (x, y) coordinate using bilinear interpolation. Handles out of bounds issue

Remarks

Use this method when coordinates may fall outside valid bounds, as it clamps inputs and gracefully handles edge cases without throwing exceptions.

Parameters

NameDescriptionDefault
x The x-coordinate (can be fractional).
y The y-coordinate (can be fractional).

Returns

The interpolated height value.

Algorithms.Heightmap.FadeValue()

The fade function smooths the coordinate values for better transitions between noise values.

Algorithms.Heightmap.ComputeGradient()

Computes the gradient for a given hash value and coordinates.

Algorithms.Heightmap.FractalBrownianMotion()

Generates Fractal Brownian Motion (fBm) noise value for the given coordinates.

Algorithms.Heightmap.RidgedMultifractal()

Generates Ridged Multifractal noise value for the given coordinates.

Algorithms.Heightmap.ComputeFalloff()

Computes the fall-off weight based on the normalized distance.

Parameters

NameDescriptionDefault
normalizedDistance The distance from the center normalized to [0,1].
falloff The fall-off parameter (0 to 1).

Returns

The weight to apply at the point.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.Iterations

Number of simulation steps.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.RainRate

Rate at which water is added to the terrain.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.EvaporationRate

Rate at which water evaporates.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.MinHeightDelta

Minimum height difference used in sediment calculations.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.ReposeSlope

Maximum stable slope angle before slippage occurs.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.Gravity

Gravity constant affecting water flow velocity.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.SedimentCapacityConstant

Controls maximum sediment carrying capacity.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.DissolvingRate

Rate at which sediment dissolves into water.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.DepositionRate

Rate at which sediment is deposited.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.CellWidth

Width of each grid cell.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.Seed

Random seed.

TheMatrix.Core.Algorithms.HydraulicErosionConfiguration.#ctor()

Parameters

NameDescriptionDefault
iterations Number of simulation steps.
rainRate Rate at which water is added to the terrain.
evaporationRate Rate at which water evaporates.
minHeightDelta Minimum height difference used in sediment calculations.
reposeSlope Maximum stable slope angle before slippage occurs.
gravity Gravity constant affecting water flow velocity.
sedimentCapacityConstant Controls maximum sediment carrying capacity.
dissolvingRate Rate at which sediment dissolves into water.
depositionRate Rate at which sediment is deposited.
cellWidth Width of each grid cell.
seed Random seed.

TheMatrix.Core.Algorithms.HeightmapHelper.GaussianBlur()

Applies a Gaussian blur to the given 2D data array. This smooths the data by convolving it with a Gaussian kernel.

TheMatrix.Core.Algorithms.HeightmapHelper.GenerateGaussianKernel()

Generates a 1D Gaussian kernel given sigma. The kernel size is chosen based on sigma.

TheMatrix.Core.Algorithms.HeightmapHelper.ConvolveHorizontal()

Convolve each row with the 1D kernel.

TheMatrix.Core.Algorithms.HeightmapHelper.ConvolveVertical()

Convolve each column with the 1D kernel.

TheMatrix.Core.Algorithms.HeightmapHelper.InterpolateHeightSafe()

Safely interpolates the height value at the specified (x, y) coordinate using bilinear interpolation. Handles out of bounds issue

Remarks

Use this method when coordinates may fall outside valid bounds, as it clamps inputs and gracefully handles edge cases without throwing exceptions.

Parameters

NameDescriptionDefault
x The x-coordinate (can be fractional).
y The y-coordinate (can be fractional).

Returns

The interpolated height value.

TheMatrix.Core.Algorithms.HeightmapMask.FilterHeight()

Filters the heightmap based on a minimum or maximum height rule with an optional fade.

Parameters

NameDescriptionDefault
rule Min or Max.
value The height value.
fade Optional fade distance.

TheMatrix.Core.Algorithms.HeightmapMask.FilterHeight()

Filters the heightmap based on a height range with an optional fade.

Parameters

NameDescriptionDefault
minHeight Minimum height value.
maxHeight Maximum height value.
fade Optional fade distance.

TheMatrix.Core.Algorithms.HeightmapMask.FilterSlope()

Filters the heightmap based on slope range with an optional fade.

Parameters

NameDescriptionDefault
minSlope Minimum slope in degrees.
maxSlope Maximum slope in degrees.
fade Optional fade distance.

TheMatrix.Core.Algorithms.HeightmapMask.CombineMasks()

Combines multiple HeightmapMasks into a single union mask.

Parameters

NameDescriptionDefault
masks An array of HeightmapMasks to combine.

Returns

A new HeightmapMask representing the union of all input masks.

TheMatrix.Core.Algorithms.HydraulicErosion.ErodeInPlace()

Simulates hydraulic erosion over the terrain using iterative processes that model rainfall, water flow, and sediment transport. Reference Link: https://github.com/dandrino/terrain-erosion-3-ways/blob/master/simulation.py

TheMatrix.Core.Algorithms.HydraulicErosion.CalculateDepositedSediment()

Calculates the amount of sediment to be deposited based on terrain height differences and capacity.

TheMatrix.Core.Algorithms.HydraulicErosion.CalcHeightDelta()

Computes height differences between grid cells based on gradients.

TheMatrix.Core.Algorithms.HydraulicErosion.CalculateSedimentCapacity()

Calculates the sediment carrying capacity of each cell based on terrain characteristics.

TheMatrix.Core.Algorithms.HydraulicErosion.CleanGradient()

Cleans and normalizes gradient vectors, assigning random directions where needed.

TheMatrix.Core.Algorithms.HydraulicErosion.Sample()

Samples terrain heights using interpolated offsets from the gradient.

TheMatrix.Core.Algorithms.HydraulicErosion.Displace()

Displaces water or sediment using directional gradients to simulate flow.

TheMatrix.Core.Algorithms.HydraulicErosion.ApplySlippage()

Applies slippage to terrain areas that exceed the repose slope angle.

TheMatrix.Core.Algorithms.HydraulicErosion.SimpleGradient()

Computes the gradient of the given 2D data array. The gradient is calculated using central differences with periodic boundary conditions.

TheMatrix.Core.Algorithms.VoxelTerrain

Remarks

TODO: Fix obj output

TheMatrix.Core.Algorithms.VoxelTerrain.#ctor()

Initializes a new instance of the VoxelTerrain class.

Parameters

NameDescriptionDefault
width Width of the terrain (X axis).
height Height of the terrain (Y axis).
depth Depth of the terrain (Z axis).
groundLevel The ground level height.

TheMatrix.Core.Algorithms.VoxelTerrain.GenerateTerrain()

Generates the terrain using 3D Perlin noise.

Parameters

NameDescriptionDefault
noiseScale Scale of the noise.
surfaceThreshold Threshold value for the surface.
caveThreshold Threshold value for caves.

TheMatrix.Core.Algorithms.VoxelTerrain.ExportObj()

Exports the terrain to an OBJ file using the Marching Cubes algorithm.

Parameters

NameDescriptionDefault
filePath The path to the OBJ file to be created.

TheMatrix.Core.Algorithms.VoxelTerrain.MarchingCubes()

Marching Cubes Algorithm Implementation

TheMatrix.Core.Algorithms.VoxelTerrain.edgeTable

Edge table for Marching Cubes algorithm

TheMatrix.Core.Algorithms.VoxelTerrain.triTable

Triangle table for Marching Cubes algorithm

TheMatrix.Core.External.OpenSCAD.OpenSCADCSGHandler.ConstructCSG()

Construct RTSCSG using OpenSCAD and returns an Obj file. This method produces the following intermediate files in The Matrix Intermediate data folder: .scad, .stl, .obj

TheMatrix.Core.External.OpenSCAD.TriangleMeshOptimizer

Optimizes a dense-triangle poly soup for rendering efficiency, typically used for generated terrain meshes

Remarks

Either P/Invokes zeux/meshoptimizer directly or summon gltfpack as process.

TheMatrix.Core.External.OpenVDB.OpenVDBInterop

Raw bindings. Will need to created a seperate managed class for making use of those indirectly.

TheMatrix.Core.Plugin.TheMatrixPluginDefinition

This is used when the module is loaded as a plugin, as oopposed to serving as a foundational dependency by many other packages.

Remarks

This serves as a temporary use - in the future we may use Divooka.TheMatrix as official package endpoint instead.

TheMatrix.Core.ProceduralGeneration.BevelOperation.Edge

A helper class to store adjacency information about an edge.

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.Mesh

Mesh class encapsulates vertices and faces.

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.Mesh.Faces

Remarks

1-indexed.

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.Mesh.ApplyTransformation()

Applies a transformation function to each vertex.

Parameters

NameDescriptionDefault
transformation

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.Mesh.Bevel()

Bevels sharp edges by inserting new vertices and creating additional faces.

Parameters

NameDescriptionDefault
amount

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.Mesh.SaveAsObj()

Saves the mesh to an OBJ file.

Parameters

NameDescriptionDefault
filePath

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.Mesh.SaveAsGltf2()

Parameters

NameDescriptionDefault
filePath

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.CreateCube

Helper method to create a cube mesh.

Returns

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.RotateXTransformation()

Returns a transformation function that rotates a vertex around the X-axis.

Parameters

NameDescriptionDefault
angleInDegrees

Returns

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.ScaleTransformation()

ScaleTransformation scales a vertex by scaleX, scaleY, and scaleZ along the respective axes.

Parameters

NameDescriptionDefault
scaleX
scaleY
scaleZ

Returns

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.TranslateTransformation()

TranslateTransformation translates a vertex by adding tx, ty, tz to its coordinates.

Parameters

NameDescriptionDefault
tx
ty
tz

Returns

TheMatrix.Core.ProceduralGeneration.ProceduralGenerationExamples.RotateTransformation()

RotateTransformation rotates a vertex around the X, Y, and Z axes in succession. The rotation angles are provided in degrees.

Parameters

NameDescriptionDefault
angleX
angleY
angleZ

Returns

TheMatrix.Core.Utilities.HeightmapColorer.ColorerConfigurations

Strongly-typed config object.

TheMatrix.Core.Utilities.HeightmapColorer.Rule

A rule is a set of conditions (joined by AND) plus a color.

TheMatrix.Core.Utilities.HeightmapColorer.Process()

Remarks

Overload for frontend use.

TheMatrix.Core.Utilities.HeightmapColorer.ParseConfig()

Parse the YAML config file and return a strongly-typed config.

TheMatrix.Core.Utilities.HeightmapColorer.LinearInterpolate()

Linearly interpolates between two SKColors by a given factor t.

Parameters

NameDescriptionDefault
from Starting color.
to Target color.
t Blend factor in the range [0,1].

Returns

A color interpolated between 'from' and 'to' based on 't'.

TheMatrix.Core.Utilities.HeightmapColorer.HtmlColorToSKColor()

Converts an HTML color code (e.g. #RRGGBB) into SkiaSharp SKColor.

TheMatrix.Core.Utilities.HeightmapColorer.LoadBitmapOrNull()

Loads an image if the path is not null/empty and the file exists. Otherwise returns null.

TheMatrix.Core.Utilities.HeightmapColorer.ToGrayscaleFloat()

Converts an SKColor pixel to a grayscale [0..1] float by averaging R/G/B.

TheMatrix.Core.Utilities.HeightmapColorer.GetMatchingColors()

Returns the colors from all rules that match the given float value.

TheMatrix.Core.Utilities.HeightmapColorer.SaveBitmap()

Saves the given SKBitmap as a PNG to the specified path.

TheMatrix.Rendering.SchematicRenderer.RaytrixGen1SchematicRenderer

SchematicRenderer/Raytrix (Gen 1) is our implement from-scratch ground-up approach renderer. It's going to be multi-scheme and supports a variety of rendering styles.

TheMatrix.Rendering.SchematicRenderer.Drawer2D

A simple 2D image drawing module hiding details of underlying implementation. This is because System.Drawing.Common is no longer part of Net 6, so to unify code use in our application code, we provide a native interface.

BasicTypes.Enums.OfflineRendererType.Automatic

Automatic chooose between Raytracer (OSPRay and custom), OpenGL, 2D procedural; Mixed for best result

BasicTypes.Enums.OfflineRendererType.QuickLayout

USDViewer style, in current implementation this refers to OSPRay-SciViz or AO

BasicTypes.Enums.OfflineRendererType.Schematic

The Matrix Visor-like auto-optimized for studying relationships; Star-Manager style

BasicTypes.Enums.OfflineRendererType.GeoMap

Dedicated renderer for producing QGIS like maps

BasicTypes.Enums.OfflineRendererType.OSPRay

Specify to use OSPRay specifically

BasicTypes.Enums.OfflineRendererType.Raytrix

Specify to use custom implemented ray tracer specifically

BasicTypes.Enums.OfflineRendererType.OpenGL

Specify to use OpenTK/OpenGL specifically

BasicTypes.Enums.OfflineRendererType.Gltf

Write out the entire scene as a single self-contained gltf file for inspection at an external program

BasicTypes.Rendering.CoordinateSystem.IsLocal

Coordinate frame

BasicTypes.Rendering.DisneyPrincipledMaterial.Metallic

Remarks

In a particular workflow, those three parameters must work together: Metallic, Diffuse and Specular. If any Metallic is 1 or Diffuse is 0, it will produce only black surface.

BasicTypes.Rendering.LuminousMaterial

Remarks

Luminous material doesn't support texture

BasicTypes.RTS.RTSEntity

A raw, pure-data representation of an entity describable by an RTS declaration

BasicTypes.RTS.RTSEntity.Fullname

Namepath including namespace and name

OSPRayEngine.InteropHelper

A think wrapper for groups of commonly used OSPRayInterop functionalities

OSPRayEngine.InteropHelper.CreateModel()

Remarks

A model contans a mesh and a material

OSPRayEngine.InteropHelper.CreateInstanceFromGroup()

Parameters

NameDescriptionDefault
transformation Expect transformation in OSPRay coordinate

OSPRayEngine.Objectification.OSPSphere

OSPRay sphere geometry supports multiple primitives

OSPRayEngine.Objectification.OSPModel

Models are geometry containers that provide material definitions, which are further contained within instances.

OSPRayEngine.OSPRayInterop.OSPFrameBufferChannel

OSPRay channel constants for Frame Buffer (can be OR'ed together)

OSPRayEngine.OSPRayInterop.ospMapFrameBuffer()

Pointer access (read-only) to the memory of the given frame buffer channel

OSPRayEngine.OSPRayInterop.ospUnmapFrameBuffer()

Unmap a previously mapped frame buffer pointer

OSPRayEngine.OSPRayInterop.ospGetVariance()

Get variance from last rendered frame

OSPRayEngine.OSPRayInterop.ospResetAccumulation()

Reset frame buffer accumulation for next render frame call

OSPRayEngine.OSPRayInterop.ospGetBounds()

Return bounds if the object is able (OSPWorld, OSPInstance, and OSPGroup)

OSPRayEngine.RenderEngine

A few tips: 1. Always use ospNewXXX() and ospRelease() pairs 2. Always follow ospSetObject() with ospCommit() 3. Always add long-lasting objects to RuntimeObjects (notably, camera, world, renderer and framebuffer); All other objects can be released when added to World

OSPRayEngine.RenderEngine.RuntimeObjects

Including: renderer, camera, framebuffer, world

OSPRayEngine.RenderEngine.AddCamera()

Remarks

Camera definition follows a right-handed coordinate (as is OSPRay), the view vector represents the forward direction of the camera, the up vector represents the up direction of the camera, the "left" direction of the cemera is the thus cross product between the two.

OSPRayEngine.RenderEngine.AddMesh()

Add mesh from a file path

OSPRayEngine.RenderEngine.AddMesh()

Add mesh from geometry

OSPRayEngine.RenderEngine.AddMesh()

Add mesh from raw geometry data

OSPRayEngine.RenderEngine.AddModel()

Add model with multiple materials

OSPRayEngine.RenderEngine.AddModel()

Add a simple basic model with a single mesh and a single material; Initial mesh and material if not yet available.

OSPRayEngine.RenderEngine.AddMeshModel()

Add mesh model with material

OSPRayEngine.RenderEngine.AddMeshModel()

Add mesh model with materials

OSPRayEngine.RenderEngine.AddSphereModel()

Add sphere model with material

OSPRayEngine.RenderEngine.AddLight()

Remarks

At least a single light is needed for Ambient Occlusion

OSPRayEngine.RenderEngine.Render()

Render continously to accumulate for better converged image

OSPRayEngine.RenderEngine.RGBAF32ToneMapping

Use this instead of UseTonemapper()

obj2usda.Obj2USDA

A simple utility to convert a single .obj file to .usda file. By utilizing Powershell automation (or use it in Pure), we can easily turn this into batch conversion.

Remarks

TODO: Currently exported USD has issue when faces share points - possibly if we export normals this problem will be fixed. (Turns out it's not has to do with normals; We can export a cube mesh from blender and compare the differences from ours)

rts2usd.RTS2USD

This is a quick utility to convert complete RTS scenes into USD files. There are two modes: 1. Self-contained (TO BE IMPLEMENTED): In self-contained mode, we package everything into a final destination (folder) as USDA, USDC and Jpg/PNG files; This mode will support all native RTS commands and geometry file formats and convert all assets to appropriate corresponding USD definitions. For targeted renderers, we will support both USDPreviewSurface, and specific material definitions that's understood by Clarisse and Houdini. 2. As-is: "As-is" is a lightweight "passthrough" convertion intended for testing purpose; In this mode, we will NOT support `csg` and all geometry references will have to be **USD**. All paths will be converted to absolute on disk.

rts2usd.Templates.USDTemplateModel

Remarks

This class needs to be "public" otherwise Razor cannot access it

FileSystem.FileFormats.GLTFReader.LoadMeshes()

Load individual meshes only; Ignore scene structure. Assume mesh has only one primitive.

FileSystem.FileFormats.GLTFWriter

References

https://github.com/KhronosGroup/glTF-CSharp-Loader https://github.com/vpenades/SharpGLTF

FileSystem.FileFormats.MeshGeometry

Represents the raw data for single piece of mesh

Remarks

Because this is shared directly with OSPRay (which is the same as Blender), we use its coordinate system convention: right-handed, +Z up, +Y right, +X towards viewer; Notice in our convention we always calls +X as forward (no matter handedness) OSPRay has no winding considerations - all triangles are rendered from all directions.

FileSystem.FileFormats.ObjReader

Material groups and vertex groups: 1. Materials when present on a single object is always exported, with `usemtl` command for seperation 2. When toggled "Material Groups" in Blender, a seperate `g` command will be provided to further define vertex groups 3. Object level seperation are provided by `o` command

Remarks

Notice that Blender considers "+Y" as forward while we consider "+X" as forward. That's why during export we should select +Y as forward in order to get +X as forward.

FileSystem.FileFormats.ObjReader.LoadMeshes()

Remarks

Objs has +Z up and +X forward, left-handed (The Matrix style); MeshGeometry has +Z up, +X forward, right-handed; So we don't need to do any conversion

FileSystem.FileFormats.ObjWriter

Write to Obj file, the cool thing is that by using this interface, you can write both vertices and faces at the same time - this can save an additional loop from the caller if it were going to write to .obj file directly.

FileSystem.ResourceFileLocator

Helps locate any physical file that is OPTIONALLY referenced as game data; Users should never rely on this because such game data are usually for decoration purposes.

FileSystem.GlobalRegistry.GetProjectNineDigitalAssetsFolderPath

0: Default 1: TFE DA drive folder path

ExternalToolingHandlers.ToolHelper.ExistsOnPath()

Check whether an executable is available to be executed as a process

ExternalToolingHandlers.ToolHelper.GetFullPath()

Find full path of executable using PATH Environment variable

Physics.PhysicalWorld.OnObjectCreated

Higher level notification event for users of PhysicalWorld

ProceduralEngine.Contexts.GeometryContext

Fluent-API

ProceduralEngine.Contexts.ImageContext

Related modules: ImageProcessor, PostProcessing, and this (ProceduralEngine) Might consider combine and trim down things to avoid over modularization.

Raytracer.Scene.SceneObject.InitializeOrFinalize

Perform all heavy duty procedural computations, generative operations, actual content loading and assembly, and perform spatial acceleration structures optimization. Called as "Initialize" before rendering starts; Called as "Finalize" during RTS parsing finished subcommands for specifying parameters.

Raytrix.Scene.Trace()

Interface requirement: tracing support

Raytrix.GeometryInstance.Trace()

Interface requirement: tracing support

Raytrix.RaytrixGen2Renderer

Raytrix is a high-level rendering API tuned specifically for Project Nine The Matrix. Raytrix uses the same coordinate system as OSPRay: OSPRay uses right-handed +Z up, thus +Y is towards right, and +X is outwards monitor (towards viewer). UV is assumed to have +X towards right, +Y towards down. And from (0, 0) to (+1, +1). Raytrix (Gen 2) is a C#-C# interop OSPRay-based renderer and thus limited to OSPRay capabilities (e.g. scientific computing).

Remarks

Technical Note: * Resource bookkeeping and management messes up with clean API - as a library we should still do it, but we should explore ways to avoid having to deal with it when exposing the API to the user. One key observation is that our renderer is usually "one-shot", meaning that we can and should just expose it as a one-shot use: just do the `Render()`, at which time all resources are setup at once and released when render is done, so the user doesn't need to know about it. * For the OSPRay backend for Raytrix, one major structural difference (which simplifies our API) is that we do not require seperate container structure for Model-Group-Instance. Instead, we consider the "GeometryModel" properties as part of all Geometries (actually it's a wonder why didn't OSPRay model it this way in the first place, like how lights can share some common properties in OSPRay).

DataLayer.BaseEntities.RTSEntityPopulator

Pure data representation for a populator

DataLayer.BaseEntities.RTSEntityPopulator.Influence

Range: 0-1

DataLayer.BaseEntities.RTSEntityPopulator.DistributionParameter

Additional textual distribution parameters if needed

DataLayer.BaseEntities.RTSModel.MaterialMapping

From surface names (as deinfed in geometry mesh) to material names (as defined in RTS)

DataLayer.BaseEntities.RTSPositionedEntity.PreviewColor

Used when generating ID maps or when quick previewing with only diffuse light

DataLayer.RTSParser

Remarks

TODO: To be replaced/merged with MiniParcel

Puretrix.Puretrix

A scripting interface for Pure. With even simpler API interface for one-shot use of Raytrix.