Now we are ready to try and create a circle in Blender: import bpy Creating a Circle using Blender Python API Now that we understand how to calculate the X and Y coordinates of a circle, we are ready to convert the parametric equations of a circle into working Python code. Using Python to calculate all the points of a Circle I leave it for you as an exercise to acquaint you with these. You might ask how we get these parametric equations? It comes from some simple high school trigonometry, the sine and cosine rules. Where (x,y) are points within the circle P and (a,b) are the coordinates of the origin of the circle. In order to draw a circle we need to use the parametric equations of a circle: We are going to try and draw a circle, first in 2D. Now that we have managed to create a simple object in Blender using Python, we are ready to go to the next step. If you don’t know what vertices, edges, faces, or meshes are check this article where I explain these: Drawing a Circle Since our object only contains a single point, we only used the first parameter(vertices). You will notice that the from_pydata() method is key. It might not look like a lot for now, but so was it not so for the Big Bang? View_layer.active_layer_(new_object)Īfter running the script, we can see that a new object with the name “dot” was created and that it only contains a single dot. Open Blender, delete the default cube and click in the Scripting tab and paste the following code: import bpy What you are waiting for? Let’s get started! Drawing an Object with a single pointīefore we even start talking about Math, let’s create an object in Blender with a single point at the origin, using the Python Blender API. This is going to be a fun project and a way to get acquainted with python and 3D modeling with Blender. The maths that we are going to use is rather simple and I will try to explain it as we go along. In this article, I am going to show you, how to create a 3D spinning donut but instead of using C code, we will be using Python and Blender. See the resources at the bottom of this page to check it out. If you haven’t watched this donut in action yet, I highly recommend you. And if spinning a donut with ASCII characters is not hard enough, and it clearly wasn’t for Andy Sloane, this code also simulates a light source so that when the donut spins you are able to see the lighting shine as the donut spins.Ī donut-shaped C code can generate a spinning donut. If you have been sleeping under a donut… I mean rock, you will not have heard yet of the donut-shaped C code that can generate a 3D spinning donut, projected onto 2D using ASCII characters.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |