Raytracer docs 🌐 FR

Home / Class reference

Class reference

Interfaces, concrete classes and core types of the engine. Interfaces (prefix I…) define contracts and live in srcs/common/; concrete implementations live in srcs/core/ and srcs/plugins/. All code belongs to the rc namespace. The signatures below are taken verbatim from the repository headers.

Each interface is a contract of pure virtual methods. A class is identified by its header path next to its name.

Core interfaces

IPlugin srcs/common/IPlugin.hpp

Base contract of every dynamic plugin (loaded as a .so). The PluginType enum holds only RENDERER and USER_INTERFACE.

virtual PluginType getType() const = 0
Returns the plugin type: RENDERER or USER_INTERFACE.

ISceneRenderer srcs/common/ISceneRenderer.hpp

Contract of a renderer (inherits IPlugin). A render produces a Render struct (size_x, size_y, std::vector<Color> pixels).

virtual void renderScene(const IScene &scene) = 0
Renders the given scene.
virtual void setPixel(int x, int y, Color color) = 0
Writes a pixel into the buffer.
virtual void markSceneDirty()
Signals that the scene changed (default implementation is empty).
virtual void stopRendering() = 0
Aborts the current render.
virtual bool isRendering() const = 0
Whether a render is in progress.
virtual int getCurrentSample() const = 0
Current sample index (progressive rendering).
virtual Render getRender() const = 0
Returns the render (dimensions + pixels).
virtual std::string getRendererName() const = 0
Renderer name (“Default”, “Viewport”…).

IScene srcs/common/scene/IScene.hpp

Container of scene data (primitives, lights, materials, camera, hierarchy) and global intersection entry point through the BVH.

virtual void addPrimitive(IPrimitive *primitive) = 0
Adds a primitive.
virtual void addLight(ILight *light) = 0
Adds a light.
virtual void addDefaultPrimitive(std::string type) = 0
Creates a default primitive from a type string.
virtual void addDefaultLight(std::string type) = 0
Creates a default light from a type string.
virtual ISceneObject *addGroup() = 0
Creates a group (hierarchy node).
virtual void reparent(ISceneObject *child, ISceneObject *newParent, int index = -1) = 0
Changes an object's parent.
virtual void removeObject(ISceneObject *object) = 0
Removes an object.
virtual IPrimitive *convertToMesh(IPrimitive *primitive) = 0
Converts a primitive into an editable mesh.
virtual Material *getMaterial(const std::string &name) = 0
Looks up a material by name.
virtual Material *createMaterial(const std::string &name) / createMaterial() = 0
Creates a material (named or anonymous).
virtual void clear() = 0
Clears the scene.
virtual float getAmbientCoefficient() / getDiffuseCoefficient() const = 0
Global lighting coefficients (with matching setters).
virtual ICamera &getCamera() const = 0
Access to the camera.
virtual const std::vector<IPrimitive *> &getPrimitives() const = 0
List of primitives.
virtual const std::vector<ILight *> &getLights() const = 0
List of lights.
virtual const std::map<std::string, Material> &getMaterials() const = 0
Material table.
virtual const std::vector<ISceneObject *> &getRoots() const = 0
Hierarchy roots.
virtual void buildBvh() = 0
(Re)builds the BVH acceleration structure.
virtual bool intersect(const Ray &ray, float tMin, float tMax, Intersection &hit) const = 0
Tests the closest intersection within [tMin, tMax].

ICamera srcs/common/scene/ICamera.hpp

Perspective camera: parameters, orthonormal basis and primary ray generation.

virtual Vector2i getResolution() const = 0
Render resolution (with setResolution).
virtual Vector3f getPosition() / getRotation() const = 0
Camera pose (with setters).
virtual double getFov() const = 0
Field of view (with setFov).
virtual Vector3f getForward() / getRight() const = 0
Camera basis vectors.
virtual int getSamplesPerPixel() const = 0
Samples per pixel (with setSamplesPerPixel).
virtual double getPixelSamplesScale() const = 0
Anti-aliasing accumulation factor.
virtual Ray generateRay(int i, int j) const = 0
Generates the primary ray for pixel (i, j).

ISceneObject srcs/common/scene/ISceneObject.hpp

Common base of every scene object (primitive, light or group). Carries the transform (local and world), name, visibility and parent/children hierarchy links. The ObjectType enum is PRIMITIVE, LIGHT or GROUP.

virtual ObjectType getObjectType() const = 0
Object kind.
virtual Vector3f getPosition() / getRotation() / getScale() const = 0
World transform (with setters).
virtual Vector3f getLocalPosition() / getLocalRotation() / getLocalScale() const = 0
Local transform (with setters).
virtual bool isHidden() const = 0
Visibility (with setHidden).
virtual std::string getName() / getTypeName() const = 0
Instance name and type name (with setName).
virtual ISceneObject *getParent() const = 0
Hierarchy parent (with setParent).
virtual const std::vector<ISceneObject *> &getChildren() const = 0
Children (with addChild, insertChild, removeChild).

IPrimitive srcs/common/scene/IPrimitive.hpp

Contract of every intersectable surface (virtually inherits ISceneObject; getObjectType() returns PRIMITIVE).

virtual bool intersect(const Ray &ray, float tMin, float tMax, Intersection &hit) const = 0
Tests intersection within [tMin, tMax] and fills the hit.
virtual AABB bounding_box() const = 0
Bounding box (for the BVH).
virtual bool isFinite() const = 0
False for an infinite object (e.g. a plane).
virtual std::map<std::string, std::pair<std::string, PropertyType>> getProperties() const = 0
Editable properties (name → text value + type).
virtual void setPropertyFloat(const std::string &key, float value) = 0
Sets a scalar property.
virtual const Material *getMaterial() const = 0
Associated material (with setMaterial).

Property types (enum class PropertyType): COLOR, VECTOR3F, VECTOR3I, VECTOR2F, VECTOR2I, FLOAT, INT, STRING.

IEditablePrimitive srcs/common/scene/IEditablePrimitive.hpp

Optional capability: a vertex-editable primitive (Triangle, Mesh). It is discovered at runtime via dynamic_cast<IEditablePrimitive*>, which leaves IPrimitive unchanged. Standalone interface (does not inherit IPrimitive).

virtual std::size_t getVertexCount() const = 0
Number of editable vertices (welded/shared vertices count once).
virtual Vector3f getVertex(std::size_t index) const = 0
World position of a vertex.
virtual void setVertex(std::size_t index, const Vector3f &worldPos) = 0
Moves a vertex in world coordinates.
virtual void onGeometryChanged() = 0
Notifies that geometry changed (recompute normals/box).
virtual std::map<std::size_t, Vector3f> getVertexOverrides() const
Vertex overrides (default: empty map).

ILight srcs/common/scene/ILight.hpp

Contract of a light source (virtually inherits ISceneObject; getObjectType() returns LIGHT). The LightKind enum is POINT, DIRECTIONAL or UNKNOWN.

virtual LightKind getKind() const = 0
Light kind.
virtual float getIntensity() const = 0
Intensity (with setIntensity).
virtual ColorF getColorF() const = 0
Floating-point color (with setColorF).
bool isHidden() const override = 0 / void setHidden(bool) override = 0
Visibility (re-declared pure).

IPluginLoader srcs/common/IPluginLoader.hpp

Contract of the plugin loader. The nested PluginHandle type bundles the dlopen handle, the IPlugin* instance and the destruction pointer.

virtual bool load(const std::string &path) = 0
Loads a .so plugin.
virtual void unloadAll() = 0
Unloads every plugin.
virtual const std::vector<PluginHandle> &getPlugins() const = 0
All loaded plugins.
virtual const std::vector<PluginHandle> getPlugins(PluginType pluginType) const = 0
Plugins filtered by type.

ICoreAccess srcs/common/ICoreAccess.hpp

Facade the core exposes to plugins: scene management, access to renderers, plugin loader, cluster module and the undo history. The CoreState enum is INITIALIZING, LOADING_SCENE, RENDERING, READY, EXITING.

virtual void clearScene() = 0
Clears the current scene.
virtual void loadScene(const std::string &scene_path) = 0
Loads a scene (with loadNewScene, saveScene).
virtual ISceneRenderer *getRenderer() / getViewportRenderer() const = 0
Main renderer and viewport renderer.
virtual IPluginLoader *getPluginLoader() const = 0
Access to the plugin loader.
virtual IClusterModule *getClusterModule() const = 0
Access to the cluster rendering module.
virtual std::string getCurrentScenePath() = 0
Path of the current scene.
virtual IScene *getScene() const = 0
Current scene.
virtual CoreState getState() const = 0
Internal core state.
virtual void requestRender() / stop() = 0
Triggers / stops a render.
virtual void historyReset() / historyCapture() / historyUndo() / historyRedo() = 0
Undo/redo history management.

Core classes

ClassLocationRole
Coresrcs/core/Core.*Orchestration: plugins, scene, rendering, UI, history, cluster. Implements ICoreAccess.
PluginLoadersrcs/core/PluginLoader.*Implements IPluginLoader: dlopen/dlclose, resolving create_plugin/destroy_plugin.
Scenesrcs/core/scene/Scene.*Implementation of IScene: primitives, lights, materials, hierarchy, BVH.
SceneParsersrcs/core/scene/SceneParser.*Reads a JSON file into scene objects.
SceneRegistersrcs/core/scene/SceneRegister.*Serializes the scene back to JSON.
SceneObjectBuildersrcs/core/scene/builder/Primitive / light dispatcher during construction.
PrimitiveBuildersrcs/core/scene/builder/Concrete construction of primitives from their data.
LightBuildersrcs/core/scene/builder/Concrete construction of lights from their data.
SceneBuildersrcs/core/scene/builder/Aggregates camera + materials + objects → Scene.
PrimitiveFactorysrcs/core/scene/factory/Creates a default primitive from a type string.
LightFactorysrcs/core/scene/factory/Creates a default light from a type string.
Camerasrcs/core/scene/camera/Perspective camera (implements ICamera).
BVHNodesrcs/core/scene/bvh/Bounding volume hierarchy node (intersection acceleration).
Materialsrcs/common/Material.hppMaterial parameters (PHONG / PBR): color, specular, reflectivity, IOR, textures…
MaterialLibrarysrcs/common/MaterialLibrary.hppPersistent library (~/.raytracer/materials): save, remove, loadAll, toJson/fromJson.
ObjParsersrcs/core/obj/Imports Wavefront .obj files.
RenderExportersrcs/core/utils/Exports the render to PNG (via stb_image).
FileObserversrcs/core/utils/Watches the scene file for hot reloading.
ClusterModulesrcs/core/cluster/Distributed rendering (implements IClusterModule): startServer, joinCluster, leaveCluster.

Math types & utilities

TypeLocationRole
Vector2f, Vector3f, Vector2i, Vector3isrcs/common/Vector.hpp2D/3D float and integer vectors, with operators, dot, cross, normalize, rotate
Matrixsrcs/common/Matrix.hppTransformation matrix.
Raysrcs/common/Ray.hppRay with origin/direction and at(t) = origin + t·direction.
AABBsrcs/common/AABB.hppAxis-aligned bounding box (min/max, hit()) + BoundingBoxUtils::surrounding_box.
Color / ColorFsrcs/common/Color.hppInteger RGBA color 0–255 / floating RGB color (fromColor, toColor).
Intersectionsrcs/common/Intersection.hppHit record: t, point, normal, front_face, uv, material, primitive.

The signatures above are taken verbatim from the repository's interface headers (namespace rc). For implementation details, refer to the corresponding files under srcs/ and to the Markdown documentation in the docs/ folder.