16+ Blender methods you already known but need to revise

Blender is a free and open 3D creation software which can be used to create cool 3d graphics for game, movie as well as turns into real product by the 3d printer. If you are new or have used Blender for sometime already then this article will help you to refer back 16+ methods you will need to revise in Blender. Lets get started.

Divide the cube in Blender

Blender offers a very simple feature which you can use to divide the cube into half. First of all switch to edit mode, then add in two horizontal edge loops (Control+R and row the mouse wheel twice then left mouse clicked) to the middle of the cube. With the loops still selected press ‘w’ and select ‘Bridge Edge Loops’ then press x key and select Face.

separate cube
separate cube

Cut the mesh in Blender

If you want to produce a cut on the mesh in Blender you can press the blender’s hot key “K”. Once you have pressed the ‘k’ key on the keyboard you will see a green square and a knife, if you left click on the mesh and move the knife you will see a line which will help you to better position the cutting edge, left click again to confirm the final position and then just press the enter key to finish the cutting process.

knife tool
knife tool

Connect two meshes in blender

You can easily connect two meshes in blender with below methods:-

  1. Create two meshes.
  2. Select both of them then press Ctrl-J to join them up!
  3. Go into edit mode, select one of the faces from each mesh.
  4. Press w then LoopTools->Bridge.
  5. Now the two meshes has been jointed up!
Blender Bridge
Blender Bridge

Starting to sculpt in Blender

In this short tutorial I will show you how to sculpt a sphere and turn it into something interesting.

First let start a new Blender project then delete the default cube and add in a sphere, Mesh->UV Sphere.

Next add in a Multiresolution Modifier

Multiresolution Modifier
Multiresolution Modifier

Next click once on the Subdivide button under the Multiresolution Modifier to increase the Preview, Sculpt and Render value to 1.

Click Once
Click Once

Then switch from the Object Mode to Sculpt Mode and make sure that Mirror x has been selected. This is just like using the Mirror Modifier on our object.

Symmetry
Symmetry

Select subtract so we can dig a hole on the object, before that make sure you switch to Front Ortho View first. Now start to sculpt a hole on the right part of the sphere.

Select Subtract
Select Subtract
Sculpt Hole
Sculpt Hole

Now you should understand why we need to set the X Mirror at the beginning of the tutorial.

Next click on the Subdivide button once, not too many time, just once to smooth the object a little bit.

Next switch from subtract to add.

Select Add
Select Add

Then create below figure.

Sculpt a cat
Sculpt a cat

Click on Subdivide again to smooth the object.

You can also press the F key then move your mouse to increase or decrease the area of the brush as well as press the Shift+F key to increase or decrease the strength of the brush.

That is it! Hope you like this short sculpt tutorial, sculpt is not easy to master, you need to keep on practicing in order to perfect your skill.

Create a mirror for an object

In this tutorial I will show you how to apply the mirror modifier to a mesh in Blender so we can model one side of that object while Blender automatically creates the other side for us. Let’s take a look.

First of all start a new Blender project and press the tab key on your keyboard to get into the edit mode, make sure you have selected the default cube before you get into the edit mode, if not press the A button to select the entire cube. Next press the W key then select subdivide to divide the cube into more division. Press A again to deselect everything, next change to WireFrame mode, switch to Front Ortho view, also make sure you are in the Vertex select mode, next press the B key and drag your mouse to select only the left Vertices of the cube as shown below.

Select only half of the cube
Select only half of the cube

Next press x and delete the selected Vertices.

Delete Vertices
Delete Vertices

Now click on the Modifier icon on the property window, then click on Add Modifier and select Mirror.

Mirror Modifier
Mirror Modifier

Under the Mirror Modifier panel do the below setting.

Enable Clipping
Enable Clipping

That is it! Now you can edit the right side of the cube and those changes will automatically reflected in the other.

Mirror Modifier Effect
Mirror Modifier Effect

Question most people always ask : How to turn the mirror of the above object into the real object

The answer is really simple, make sure you are in the Object mode then pressed on the Apply button on the Mirror Modifier panel.

Turn the mirror object into solid object
Turn the mirror object into solid object

Now you can paint on the cube as you wish.

Using the Spin feature to trace and create a bottle with Blender

First thing you need to do is of course to start up your Blender software. Then follow these steps to create the bottle.

1 Delete the default cube on the new Blender project screen (Refer to the previous tutorial).

2 Find an image of a bottle on the Internet and downloaded it to your computer.

3 Set that image as the background image of your new Blender project by pressing the N key to bring up the property panel, then scrolled down to where it says Background Image and checked on the checkbox beside “Background Image”. Next click on the “Add Image” button and then click on the “Open” button to select the bottle image you have just downloaded from your computer! You can now press the N key again to hide the property panel.

Load background image
Load background image

4 You will not see the image on the background of your project yet after you have loaded it because you need to do this extra step before you can see it. Set the view of the 3d window to Front Ortho view (Refer to the previous tutorial) and you should be able to see that image now! You can use your middle mouse’s wheel to enlarge that image or make it smaller as you wish.

Background Image
Background Image

5 The next thing you need to do is to add a plane (Refer to the previous tutorial) then select ‘Edit Mode’ from the 3d window header. When you are in the edit mode, select ‘Top’ under the View tab from the 3d Window.

Top View
Top View

6 Pressed the A key to deselect everything then select three vertices from the four by right click on the first vertice then Shift–Right Click on the remaining two.

SHIFT-Right Click
SHIFT-Right Click

7 Next delete those vertices by pressing the x key and select ‘Delete Vertices’ from the pop up panel. Now get back to the Front view again by selecting ‘Front’ from the View tab under the 3d Window.

8 Next return to Object Mode from the Edit Mode and drag the blue arrow of that solo vertice all the way up to the top of the bottle.

Vertice on top
Vertice on top

9 Now change the mode back to ‘Edit Mode’ and then with the solo vertice selected (if it is not select then right click to select it) press the E key and drag the mouse to a new position as shown below, then left click to position that new vertice on the new position. Press the E key again to create another new vertice then drag it to the next position and left click to position the vertice on that new position. Repeat the above steps until you have traced half of the bottle and putting the final vertice on the bottom center of the bottle.

New Positon
New Position
trace bottle
bottom center of the bottle

10 If the 3d cursor (the one with the red and white circle) is not in the center of the bottle then left mouse click on the center of the bottle to place the 3d cursor over there (as shown on the top image).

11 Next switch to Top view then press the A key to select all the vertices that surrounded the bottle. You will see a orange line across all the vertices if you have selected them all.

12 Next look for the Spin button on the right hand sidebar of the 3d window and click on it. Under the Spin section set the Steps to 15 and Angle to 360 degree.

Spin Button
Spin Button
Spin
Spin

13 Now press the middle mouse button and move the mouse around a circle to turn the bottle around and see the outcome. Press A to deselect everything.

3D Blender Bottle
3D Blender Bottle

14 Now press the A key again to select everything then under the Mesh tab on the 3d window header select Vertices->Remove Doubles.

Remove Doubles
Remove Doubles

15 Next we need to patch the holes on the bottom and the top of the bottle. First press A to deselect everything. Next click on the ‘Edge select’ icon on the 3d window header to select it. Now turn the bottle around so you can see the top of it by pressing the middle mouse wheel and move the mouse around a circle on the mouse pad. Now do this, hold down both the ALT and N key and right click on one of the edges that surrounded the top of the bottle at the same time to select all the edges that surrounded the top of bottle. If you find it hard to locate the edge you should scroll the middle mouse wheel to enlarge the bottle. With the edges selected press the F key to fill up the top hole. Now press A to deselect everything then turned the bottle around and repeat the above steps to fill up the bottom hole as well.

Edge Select
Edge select
Top Edges
Top Edges

16 Now lets see how the bottle looks like by selecting ‘Solid’ from the Viewport Shading tab which is under the 3d window header.

Solid
Solid

17 That is it, you have completed this lesson of the Blender tutorial.

Blender Bottle
Blender Bottle

How to use node editor in Blender?

In following tutorial I am going to show you how to play around with Blender’s node editor which is very useful when it comes to edit the material of an object.

1 Lets open up any blender file you have just created by selecting the File menu and then choose the “Open Recent” tab to select any blend file you have previously saved, I select a bottle. Next change the Blender Render selection to Cycles Render. Now split the current window into two by moving the mouse cursor to the top right corner of the window and when you see a cross appears on that corner you left click and then drag the window down to split the 3d window into two.

Split Windows
Move cursor to here!

2 Next change the upper window to the node editor window by clicking the little white cube on the upper 3d window header and select the “Node Editor” tab from the pop up panel to turn the upper window to Node Editor window.

Node Editor
Node Editor

3 Now you should see two windows, the node editor window at the top and the 3d window at the bottom.

4 Now lets add a mix shader to the object. Right click on the bottle in the 3d window then on the right hand sidebar select the Material tab and create a new material. Change the Diffuse BSDF to Mix Shader under the Surface selector. You should now see two boxes appear on the Node Editor.

Node Editor
Node Editor

5 Next Shift-A then select Shader->Diffuse BSDF to add the Diffuse BSDF shader to the node editor. Move the Diffuse BSDF shader box to the top left of the Mix Shader then left click on it to put the box there. Next left click on the green circle of the Diffuse BSDF shader and drag the link to the top green circle of the Mix Shader and release the link to connect the two shaders together. Next add the Glossy BSDF shader with Shift-A then select Shader->Glossy BSDF and do the same thing to connect the Glossy BSDF shader to the bottom green circle of the Mix Shader.

Glossy-Diffuse-Mix Shader
Glossy-Diffuse-Mix Shader

6 Next click on the color bar of the Diffuse Shader and change the color to blue on the color wheel.

Color Wheel
Color Wheel

7 Next change the Fac value on the Mix Shader to 0.7 which means the Diffuse Shader which is connected to the first circle of the Mix Shader will influence up to 70% on the bottle material and Glossy Shader will only influence 30%.

Fac Value
Fac Value

8 As we change or add a new material to an object the Surface value on the Material Panel is changing as well. That means when we change a value of a shader on the Material panel the value of that shader on the Node Editor will change as well and vise versa.

Surface
Surface

9 Alright, that is about it for this tutorial, you can add lots of effect to the bottle besides shader, just play with the effect and see by yourself what will happen when you add a new effect to the Node Editor. For example you can add the Image Texture feature to the editor then add texture to that bottle!

10 Save your file to a new name by selecting Save As from the File menu before you close the Blender program.

3D and Node Editor Window
3D and Node Editor Window

Create terrain with the landscape addon in Blender

For those of you who want to create terrain in Blender you do not need to start from the beginning anymore because all you need to do is to create the landscape mesh under Mesh->Landscape! You can then change the type of landscape to suite your need or modify it in the edit mode.

blender landscape
blender landscape

This addon is not a default addon so you do need to activate it under the addon console.

How to create 3d terrain in Blender without a addon

This quick tips will show you how to create a 3d terrain with Blender 3d Render. This tutorial assumes that you have already known how to use the Blender’s basic features such as switching from the edit mode to object mode and etc so it won’t show you those steps anymore.

Follow these quick steps to create your first 3d terrain for 3d game or whatever purpose you wish.

1) Start a new Blender Render project and delete the default cube.

2) Create a Mesh Plane and resize it to 10 time the original size.

3) Switch to edit mode and subdivide the plane for 5 times.

4) Press the A key to deselect everything then enable the Proportional Editing mode under Proportional Editing and select Random falloff under Proportional Editing Falloff (The one which is next to Proportional Editing button).

Proportional Editing Mode
Proportional Editing Mode
Proportional Editing Falloff
Proportional Editing Falloff

5) Make sure you are in the Vertex select mode. You can either select a few vertexes with Shift-Right Click (or press the B key then select an area) or just Right Click to select only one vertex. Next press the G key, then Z key and type in 0.5 or -0.5 to move the vertex(es) upward or downward to create a mountain or an alley in the new 3d terrain. You can use the mouse wheel to increase or decrease the area of influence of those vertexes.

6) Change the light to sun light.

7) Divide the 3d window into two part horizontally. Switch the left 3d window to UV/Image Editor window then create a new image and name it ‘Terrain’. Next switch the UV/Image Editor’s mode to Paint mode.

8) Next select all the vertexes on the right 3d window and then press the U key to select UV Mapping Unwrap.

9) Change the 3d window from Edit Mode to Texture Paint Mode and it’s Viewport Shading to Texture then add an Ambient Paint Slot (anyone will do because we will change it later).

Add Paint Slot
Add Ambient Paint Slot

10) Create a new material and a new Texture and then assigned the new terrain from the UV editor to that new texture and uploaded a texture you have downloaded from the web (let say a sand texture) to this project.

You need to select Terrain to paint
You need to select Terrain to paint
Add New Texture
Add New Texture
Upload a new texture
Upload a new texture

11) Now you can start to paint on the 3d window, you can adjust the brush size and the brightness of the texture from the tool editor on the left of the 3d window.

Adjust Radius and Brightness
Adjust Radius and Brightness

12) Next add more textures you need and continue to paint on the terrain.

13) After you have satisfied with your terrain you can then adjust the camera angle and render it.

14) Save the image and the Blender file.

15) Below is how the 3d terrain looks like.

3d terrain
3d terrain

The blender render 3d terrain is only good for not so high quality gaming graphic, if you need a realistic looking 3d terrain then you should use the cycles render instead.

How to import the ready made material into your Blender project

After you have created an object in Blender Cycles, you will need to start creating the material for that object which most of the time will take many man hours to do so plus you will need to manage the complicated node structure by yourself which most of the time can contain up to 50+ nodes. As a game developer, those time can well be spent to write beautiful program for your game instead of creating material for your game graphic. Luckily Blender has a feature calls Link which can help you to directly imports and assigns a material on your newly created object. Here is how to do it…

1) Search for a free to download Blender material file and downloaded it to your pc.

2) Start a new blender cycles project and create your first simple Mesh object. Next split the 3d window into two part, change the top window to node editor window, select the object in the bottom window then create a new material under the property window on the right of the 3d window and click on the Use Nodes button under Surface.

3) Make sure you are in the object mode, go to File->Link, then look for the Blender file you have just downloaded from the Internet, click to open it’s material library then pick a material file which you need.

Link from Library
Link from Library

4) Click on the little brown ball button at the bottom of the Node Editor window and select the material which you have linked into your project.

Select Material
Select Material

5) That is it, render the object with the new material assigns to it and see the outcome by yourself.

Look at the Node Editor
Look at the Node Editor

You can assign another new material on different object from different group on the same project, for example a ship or a house as you wish to.

How to create a cloth simulation effect with Blender

The concept behind this new Blender project is simple, the cloth will drop from the top and landed on a sphere object.

First let open a new Blender file and switch to Cycles Render, we are going to turn the default cube into a sphere. With the default cube is still selected press the Tab key to get into the Edit mode. Now press the W key and then select Subdivide Smooth for 3 times. The previous default cube will become a sphere.

Subdivide Smooth
Subdivide Smooth

OK that is it, now deselected everything by pressing the A key and then get out of Edit mode by pressing the tab key.

Next press Shift+A and then Mesh->Plane to create a plane which we will use as the cloth.

Create a Plane
Create a Plane

Move the plane up so it is just slightly above the top of the sphere. Press S then 2 and press enter to scale the plane. Create another plane with the same method then move it down so it touches the bottom of the sphere, then press S and 3 to scale it, this plane will become the ground in this project. Now right click to select the sphere and scale it down a little by pressing S then move your mouse inward and then left click to confirm the size. You should also move the top cloth down to a new position as explained before. Now you should end up with the below position if you do it right.

Cloth-Cube-Ground
Cloth-Cube-Ground

Now lets create another new window and turn it into UV Image Editor.

Split Window into Two
Split Window into Two

Next with the top plane still selected go to the property panel and select Add Modifier then select Subdivision Surface, under Subdivisions set both view and render value to 5 and click on the Apply button.

Subdivision Surface
Subdivision Surface
Set both View and Render value to 5
Set both View and Render value to 5

Next get into Edit mode on the 3D View window then press the U key and then with the cloth still selected click Unwrap. Next go to the UV Image editor window and open a new image which we will use as the texture for the cloth. You can download any image texture which you wish as long as it does not has watermark on it.

Open an Image from the UV editor
Open an Image from the UV editor

Next with the cloth still selected on the UV Image Editor press the S key and then move the mouse outward to cover the entire image.

cover the entire texture with cloth
cover the entire texture with cloth

Next go to the property panel and select the Material tab then click New to create a new Material and click on the button at the side of the Color palette then select Image Texture.

Image Texture
Image Texture

Next select the image texture you have just imported into your project.

cloth texture
cloth texture

OK now we can close the UV Image Editor window (I assumed you already know how to do that :))

Now for the fun part, with the cloth still selected press on the last tab which is the Physics tab on the property window then click on the Cloth button.

Click Cloth Button
Click Cloth Button

Under the Cloth sub panel set the Quality steps to 10 and under Presets leave it as Cloth Presets.

Set Quality Steps to 10
Set Quality Steps to 10

Under the Cloth Collision sub panel set the both the Cloth Collision and Self Collision Quality to 10.

set quality to 10
set both the cloth collision and self collision quality to 10

Next right click to select the sphere and this time under Physics panel select the Collision button, do the same to the ground as well.

Alright, now we can take a look at how the physic simulation works. Press the right arrow Play button at the bottom of the 3D window. You can either leave the animation till the end or pause it at the right spot which you wish to by clicking on the pause button.

click play
click play

You should see the below outcome (at a certain point of the animation).

cloth simulation
cloth simulation

Alright now lets create a texture for the ground. Right click the ground object then go to the property panel and select the Material tab. Click New as before then just leave everything as default and change it’s color to something you prefer.

select the color for the ground
select the color for the ground

Next press A to deselected everything, then change the View to Front Ortho. Press A and create a new plane. Scale it up to 3 times it’s current size. Rotate the plane on the Y axis by pressing the R key then the Y key and type in 90 then enter. Now you should see something like below, if not then move the new plane a little bit to the left of the sphere.

Move plane to left
Move plane to left

With the new plane is still selected, go to the material panel again and change the surface to Emission then pick a light blue color as it’s color and set the strength to 4.

Texture for the Emission plane
Texture for the Emission plane

Also because this plane will serve only as a reflector therefore we don’t want to show it in our camera view. Go to the Object tab and under Cycles Settings’ Ray Visibility unchecked the Camera’s checkbox.

Hide the Plane
Hide the Plane

Now lets click on the World tab (the one looks like earth) on the property panel then click on Use Nodes button, next click on the button at the side of Color palette and select Sky Texture and then set the strength to 7. You can play around with the sky texture and find the best effect for the object background.

Sky Texture
Sky Texture

Next press N to open another property panel and checked the Lock Camera To View checkbox under View, press N again to close the property panel.

Lock Camera
Lock Camera

Switch to camera view and position the object within the camera range. You can increase the Camera coverage by changing the Resolution of the camera screen under Resolution which is under the Dimensions sub panel of the Camera main panel.

reset the camera resolution
reset the camera resolution

One last thing to do here is you need to set the Samples value under the Render box to 500. This is under the Camera tab->Sampling sub panel.

Sampling
Sampling

That is it, now click on the Render button at the top of the Camera panel then you will see the below outcome. Don’t forget to save the image after this!

How to create a simple glass reflection effect with Blender Environment Texture

In this tutorial I am going to show you how to create a simple glass reflection effect with the Blender Environment Texture.

1) First start up a new Blender project, change to Cycles Render then create a plane below the default cube and scale it up to 3.5 time.

s 3.5
scale the plane to 3.5 time

2) Next under the property panel select world and then under the Surface sub panel click on the Use Nodes button to create new node. Select Environment Texture from the button besides the Color palette. Load the texture which you wish to show up as the background image for this project and set it’s strength to 5.

use environment texture to light the scene
use environment texture to light up the scene

3) Next delete the default lamp (Right click on the lamp then press x and delete).

4) Now select the plane and create a new material under it’s Material menu, leave everything as default but change it’s surface shader to Glossy BSDF.

use Glossy BSDF
use Glossy BSDF

5) Next switch back to the world menu and under Ray Visibility uncheck the camera checkbox so we can now hide the background image but still using it to light up the scene.

Hide Background
Hide Background

6) Next under the Render menu turn the background scene into transparent.

set background to transparent
set background to transparent

7) You might also want to complete the following steps to reduce the noise and the fireflies effect on the object.

Sampling Menu
Sampling Menu
Light Paths Menu
Light Paths Menu

Now the cube will float on top of a shinny glass as shown in the following image.

Blender Glassy Effect
Blender Glassy Effect

How to light up a Blender object with Environment Texture

In this tutorial I am going to show you how to light up a Blender object not by using the default lamp but just by using a background image.

Start a new Blender project then switch it to Cycles Render and then go to the property panel and select the world tab. Under the Surface sub panel click on the Use Nodes button and then click on the button beside the color palette and select Environment Texture, next click on open and select an image as the background image for the scene!

Environment Texture
Environment Texture

Turn off the lamp by clicking on the eye icon once so we only light up the default cube with the background image.

All Scenes
Under All Scenes turn off the Lamp

Next under the Render tab Film sub panel checked the Transparent checkbox so the background image will not appear in the scene but still will light up the default cube.

Turn Off Background
Turn Off Background

Next select the default cube then go to the Material tab and click on the Use Nodes button. Select Magic Texture from the button beside the color palette.

Change to Magic Texture
Change to Magic Texture

Now click on the Render tab and render the scene.

Render Object
Render Object

As you can see the background image has replaced the lamp to light up the object’s scene.

Playing around with Spot lighting in Blender

Start up a new Blender project, make sure you select the Blender Render engine. Create three cubes and a ground. Then change the color of the World to blue or something you like it to be. Click on the lamp and under the Object Data tab turn it into a spot light. Play around with these features.

  1. Change the color of the lamp to something which you like, for example, light brown color.
  2. Increase the Energy level of the Lamp to around 5.
  3. Increase the Falloff Distance of the Lamp to around 50.
  4. Change the Samples value of the Shadow to around 10 to reduce the grainy appearance.
  5.  Increase the Soft Size value of the Shadow to blur the shadow and thus give it a softer look.
  6. Change the Size of the Spot Shape to around 50.
  7. Increase the Blend value of the Spot Shape to soften the edge of
    the cast circle of light.

This is how the outcome looks like.

Three Cubes
Three Cubes

The objects above are totally being light up by the lamp.

Insert keyframe for the light in Cycles Render

I have just discovered this very nice method to insert keyframe to a light when we are in the Cycles Render mode so that the lamp will change color from one frame to the next. Here is how to insert a keyframe to the light.

i) In cycles render select the light by left clicking on it.

ii) Before you do anything make sure you are at frame 1 by looking at the timeline editor.

current frame
current time frame

iii) Select the object data tab of the lamp.

object data
object data

Under Nodes click on the Use Nodes button then change the color of the lamp to any color, next press ‘i’ when the cursor is on the color box to insert a keyframe. After you have inserted a keyframe to the lamp the color box will get a border which indicates that you have successfully inserted a keyframe.

iv) You can now move to frame number two under the timeline editor and insert the next keyframe using the same method.

v) It is simple to change the color of a mesh by just changing the color of the lamp as mentioned above!

Now switch to the Rendered viewport and press Alt-A to render the animation and see how the lamp changes color through time.

Create IK bone in Blender

If we have activated the IK or inverse kinematics in our bone structure then by moving a piece of bone will then move the other bones attach to it. In this simple example I will show you how to apply inverse kinematics on a group of bones. Before we start please take note that I do not change the name of any bone so for example, bone number one will remain as Bone and the second bone will be called Bone.001 and so on.

  1. First let start to create three pieces of bone as usual, SHIFT-A then select Armature->Single Bone.
  2. Next switch to edit mode and start to extrude that bone upward, select the tip of the bone and start to extrude it upward, press E for extrude and Z to move upward in the z direction. Extrude two times so now you have three bones.
  3. Still in edit mode select the top most bone and under the Bone tab under Relations->Parent delete Bone.001 to make that top bone not attach to any parent object.
  4. Next select Bone.001 which is the second bone from the top and switch to pose mode. Add an inverse kinematics constraint to the bone under the Bone Constraints tab.
  5. Next under the Target area select Armature and under the Bone area select Bone.002. Bone.001 should now turn yellow indicating that the IK settings have now been activated!
  6. That is it, now still in the pose mode select the top most bone and move it around in the x, y or z direction with the x, y, z arrow!

    bone
    bone IK
  7. You will see the bottom two bones will follow the top bone!

IK is very useful when it comes to creating a bending pipeline like below…

ik pipe
ik pipe

How to run the python script in Blender text editor

For the python learner Blender is one of the real deal to show our python programming skill, today I have take a look at this cool Blender’s Text Editor which we can directly type in the python code and run it to see the outcome in the Blender’s 3D View Editor.

Blender’s Text Editor is where we will write our python script and run it before we actually create a Blender addon and install it in Blender. To use the Text Editor all we need to do is to click on the 3d cube button on the bottom of our 3D View window and then replace the 3D View Window with the Text Editor window, make sure we have two windows open so we can see the python script’s outcome from another 3D View window.

Open Text Editor
Open Text Editor

Next click on the New button bellow the Text Editor window to create a new Text Editor.

Click New
Click New

Now we can start to enter the python script into that new text editor, lets input below script into the text editor and see the outcome by ourself.

import bpy

scene = bpy.context.scene
material = bpy.data.materials.new("PKHG")
material.diffuse_color = (0.7,0.0,0.5)
material.diffuse_fresnel = 3.0
material.darkness = 0.3
material.diffuse_intensity = 0.5
material.diffuse_intensity = 0.7
material.diffuse_toon_size = 3.0
for obj in scene.objects:
    obj.rotation_euler = (0.785398, 0.785398, 0.785398)
    obj.active_material = material

Next click on the Run Script button at the bottom of the editor and see the outcome as follow on the other 3D View window.

The selected object
The selected object

Basically what that above script does is to rotate the selected color cube in an angle and includes various other settings into the selected cube.

If you are interested in Blender programming then Blender Documentation is where you can find all the Blender functions that you can use in your python program. Besides that, this blog will also show article regarding how to write a python program which we can use in Blender from time to time so make sure you bookmarked this blog (I don’t collect email from you, only bookmark my blog and return for more interesting articles if you want to).

How to add modifier to blender object programmatically?

In this tutorial I am going to add a Bevel modifier to a cube in Blender with python script. Applying a Bevel modifier to an object in Blender is super simple, all we need is to write these few lines of code.

import bpy

scene = bpy.context.scene
material = bpy.data.materials.new("PKHG")
material.diffuse_color = (0.539,0.546,0.0042)
material.diffuse_fresnel = 3.0
material.darkness = 0.3
material.diffuse_intensity = 0.5
material.diffuse_intensity = 0.7
material.diffuse_toon_size = 3.0
for obj in scene.objects:
    obj.rotation_euler = (0.785398, 0.785398, 0.785398)
    obj.modifiers.new("Bevel", "BEVEL")
    bpy.ops.object.modifier_apply(apply_as='DATA', modifier="Bevel")
    obj.active_material = material

If you look at the 3D View window now after you have run the python script you will see this yellow cube with bevel effect!

Applying Modifier
Applying Bevel Modifier

How to export Blender object into Panda3D 1.9.2 game engine

Panda3D 1.9.2 is a nice game engine which we can use it to create commercial game or free game and then either sell or distribute our game on the gaming market place. One cool thing about Panda3D is that it actually allows us to import object creates in Blender to our game which we can then use it as a gaming character. Today I am going to show you how to export Blender object into Panda3D 1.9.2 gaming engine with ease.

First of all if you are using Blender 2.77 and above then you will need to import YABEE addon into Blender before you can export your model in the EGG format to the Panda3D game engine. Chicken addon does not work on Blender 2.77. Therefore go ahead and download the YABEE addon first from the above mentioned link and then go to File->User Preferences and click on the Add-ons tab then click on the Install from File button at the bottom of the Add-ons panel and import the YABEE addon into blender.

Next create what ever object you wish to in Blender and then select that entire object which you want to export and go into the Edit mode, under the Edit mode press the u key then select Unwrep. Next go back to Object mode and go to File->Export->Panda3D(.egg). As for now follow below screen shot to do the export setting on the sidebar of the addon panel. You can adjust the setting later on.

YABEE EGG
YABEE EGG

After you have selected the folder to export the EGG file and provided the file with a name, for example boy.egg, click on the Export to Panda3D EGG button to export the file. You will find out that there are one egg file and one tex folder in that folder, the tex folder is where YABEE exports and keeps all the textures for the Blender’s model you have created.

Now lets put the object into the game. Create a python file and name it boy.py as follow in the same folder with the exported egg file.

import direct.directbase.DirectStart

class Boy:

	def __init__(self):
		base.setBackgroundColor(0,0,0)
		self.track = loader.loadModel("./boy.egg")
		self.track.reparentTo(render)

b = Boy()

base.run()

Notice that the ./boy.egg is the relative path to the egg file. Next under your windows command prompt type in ppython boy.py to run the program. You must use ppython instead of python or else you will see an error because Panda3D uses it’s own set of python tool to run the program. You should have seen below object after you have started the program,

Panda3D
Panda3D

if not then press on the left mouse button and drag the mouse within the Panda panel screen above to reveal the object. If you are interested in learning Panda3D programming then you can find it all in https://www.panda3d.org.

That is all for this article, I wish you good luck in your next Blender 3d project!