3D

Idea of the 3D painting is very simple. 3D model has render texture from PaintCraft canvas. And all incoming input events forwarded to that PaintCraft canvas controller.

To make it Works you need make following steps

  1. Setup new blank page config with size which you want to use on your model

  2. Add PaintCraft prefab to the scene and use page config created before. Place this prefab somwhere where player wont see it like on Vector3(2000,2000,-2000) position

  3. On your 3D model you need to add PaintcraftCanvas3DPlane component and link PaintcraftCanvas property to paintcraft prefab which you add on 2d step

  4. Now you need event source. some 3D object which will send events to paintcraft canvas throgh your 3D model. Bellow you can find steps used in 3D scene with unity standard 3DPersonController

    1. On the same object as 3D person controller add LineConfig component. And if you want to change active tool parameters later you need to work with this component

    2. Add Drawing3DController component to the same object. You can change parameters if you like by default it will listen mouse events (down|move|up), make raycast from the center of the screen and forward this to the PaintCraft controller. Here is example:

As usuall source code is not obfuscated and you can open it in code editor and check how it works and adjust it to your needs.

Also you need to understand that you are painting on the texture using uv coordinates picked up from model. That's mean that your model must be prepared properly, it's better to place adjucent uv regions together so if you move your brush across triangles on your 3D model the your path on UV texture become smooth.

Here is a car model and region texture

You can see here that each window has own place on UV texture (each window, each wheel or any another pices). so if you will start painting window (blue arrow) and move brush to the car roof, some wired tings wont happens. Without region file paintcraft take first point on windo, then second on the roof and interpolate the line and make direct line acros car side, bumper and so on. This is why it's critical to prepare model properly.

Last updated