christian-vorhemus / procedural-3d-image-generation

This repository is demonstrating how Blender can be leveraged to create synthetic machine learning training data for computer vision tasks.
MIT License
30 stars 7 forks source link

Stroke parameters for sculpting #1

Open dawnKalo opened 4 years ago

dawnKalo commented 4 years ago

Hi,

Nice job. I write scripts in Blender as well for other tasks, I would like to understand more about the stroke parameters for sculpting:

        stroke = {
            "name": "stroke",
            "mouse": (0,0),
            "pen_flip" : pen_flip,
            "is_start": True if i==0 else False,
            "location": coordinate,
            "size": 50,
            "pressure": 1,
            "time": float(i)
        }

The documentation is quite poor: https://docs.blender.org/api/current/bpy.types.OperatorStrokeElement.html

Specifically, for location and mouse. How did you defined the location? according to the viewport or the object location?

When I do it manually in Blender, I don't see the printed script in info as I see in other tasks.

christian-vorhemus commented 4 years ago

The location coordinates passed to OperatorStrokeElement are coordinates of viewport. If you start with a standard cube at position (0,0,0) with size (2,2,2) and you apply the following strokes:

stroke1 = {
  "name": "stroke",
  "mouse": (0,0),
  "pen_flip" : False,
  "is_start": True,
  "location": (0,0,1),
  "size": 50,
  "pressure": 10,
  "time": 1.0
}

stroke2 = {
  "name": "stroke",
  "mouse": (0,0),
  "pen_flip" : False,
  "is_start": False,
  "location": (0,1,1),
  "size": 50,
  "pressure": 10,
  "time": 2.0
}

you'll get a deformation along the Y axis on top. If you move the cube to position (2,0,0), apply the transformation (Ctrl + A -> Location) and use the same brush strokes as above, nothing will happen. But if you now set the location of the strokes to (2,0,1) and (2,1,1) respectively, you'll see again the deformation on top.

yangky11 commented 3 years ago

Hi,

Thanks for the explanation! I have a related question about sculpting. For some sculpting tools such as Grab and Snake Hook, you have to click on the shape and then drag your mouse. Is it possible to do this in Python scripts? I tried the sculpting code in this repo, it essentially places strokes as individual points. I'm not sure whether it can work for Grab and Snake Hook.

Thank you!