--- tags: Texturing, 2023 --- # VR painting experiment Blender has a 3d brush. This brush is used for sculpting and is planned to be used for texturing. When sculpting or painting a brush operation is performed. This operation transfers 2d mouse cursor to a 3d position. When using XR input devices we should be able to skip this transformation and use the 3d position/direction to cast the location of the brush to the object. ## ```plantuml namespace blender::dna { class wmWindowManager { } class wmXrData { } class wmXrRuntimeData { } class XrActionMap { } class XrActionMapItem { +op: char[MAX_NAME] +op_properties: IDProperty } wmWindowManager -> wmXrData: xr wmXrData->wmXrRuntimeData: runtime wmXrRuntimeData--> XrActionMap: actionmaps XrActionMapItem <- XrActionMap: items } ``` SCULPT_OT_brush_stoke will have a brush_object pointer property. When this is set in stead of the mouse cursor the location and transformation of the `brush_object` will be used to cast a ray onto the sculpt object. `over_mesh` already has a `wmOperator` that could be used to read the `brush_object`. `SCULPT_stroke_get_location` / `SCULPT_raycast_init` requires the sculpt object as well. `SCULPT_raycast_init` will be splitted into mouse cursor/brush_object. Inside the XrActionMap we want to start the SCULPT_OT_brush_stroke operator with a brush_object that will follow the XrController. :::info - The mapping between the Xr Controller and the brush_object still needs to be looked into. - Check into the scene inspection add-on and API documentation how to do this. ::: :::info - Internally mouse position is used to identify movement. Somehow we have to do similar tricks to identify movement. (`initial_mouse`). Detection of movement is done inside `paint_stroke`. - We might want to abstract this away and support mouse input class and object input class. ::: ```plantuml package blender { class SculptSession { } class StrokeCache { } class Object {} SculptSession->StrokeCache: cache StrokeCache->Object: brush_object } ``` ```plantuml package blender::sculpt { class ScultRaycaster { mouse: float[2] object: Object } class SculptRay { position: float3 direction: float3 rotation: float } } ```