Search This Blog

Tuesday, 6 September 2022

ANIMATION IN BLENDER 2.79

 

 ANIMATION PART 1 -NOTES

INTRODUCTION - BASIC CONCEPT OF ANIMATION.

Animation is the process of making something appear to move  by showing a series of still images, one after another, each one slightly different from the previous one, creating an  illusion of motion. This is the concept used in movies. When the images are moved at a rapid speed of 24 pictures(frames) per second or more, then the human brain perceives such change as continuous, which is based on the concept of "Persistence of vision".

TECHNICAL DETAILS

FRAMES, FRAMES PER SECOND, DIFFERENT VIDEO STDS –NTSC,PAL ETC.


Each image in animation is called a frame. Normally 24 frames are shown per second (fps). In Blender we set up scenes using the different characters called object, which perform some action. To enhance the quality of the scene, colored back ground, lighting are included. The whole action is displayed on the computer screen. This is captured by the camera, set up inside Blender and converted into still images which when assembled sequentially becomes a video.
A series of videos assembled with proper sound effects becomes a movie. For display on television the American Standard NTSC specifies 30 fps and the Australian Standard PAL follows 25 fps.
A one minute video, will have 60X24=1440 frames, for 24 fps.


TIMELINE EDITOR.


Time line editor is basically used to set and visualize the frame movement, with its control to start, stop and rewind buttons and provision for setting the total number of frames. It is used for setting the key frames.

 PART 1

OBJECTIVE : BASIC ANIMATION -TO MOVE AN OBJECT FROM POINT A TO POINT B AND THEN TO POINT A.

STEPS

1.ADD AN OBJECT TO ANIMATE.


2.SET FRAME RATE AS 24 FPS, TOTAL NO OF KEY FRAMES 240. START FRAME IS 1 AND END FRAME IS 240.

3.SET KEY FRAME FOR THE OBJECT AT POINTS A, B AND  A AGAIN. SAVE FILE.


4. PLAY ANIMATION.

STEP 1 :ADD AN OBJECT TO ANIMATE

To add an object in 3D window, set your cursor in the 3D window and then press Shift+A keys. A pop-up menu will appear. Here select "Mesh" and then "Cube". A Cube will be added at the location where the cursor was last positioned.

Set the view to Front Ortho view, by pressing "1" and then "5", in the Numpad.

To see the x, y, z location coordinates of the cube,  press "N" key while the cursor is still in the 3D window. A  properties panel will appear on the right side where you should be able to see the location coordinates of the Cube. Set it to x=0,y=0, z=0. Let us assume that this will be point A where the Cube shall be located in  our animation.


STEP 2 : SET START AND END KEY FRAMES


The Start and End key frames are set to 1 and 240 by default. The frame Rate per second(fps) is set to 24fps, the default value.


STEP 3:SET KEY FRAMES

Key frames, are set in the 3d Window, key frame is visible in the Time line window. The current location of the cursor, indicated by the vertical green line in the Time line window is the frame number which we want to set as key frame. When a frame is set as key-frame, a small, vertical yellow line will appear along with the green line in the TimeLine Window.

To set a key-frame, SELECT the Cube, by clicking the Right Mouse Button(RMB) on the Cube. An yellow border-line will appear around the Cube. (If you want to deselect the cube,press "A" key). Let the Cube remain be selected. Note that the current location of the Cube is 0,0,0.

To SET KEY FRAME, press  the "I" button and then click on "Location", in the pop-up menu.A key frame is set  for this location of the Cube. This is indicated by the small yellow line, in the Time Line Window.

Save the File, by pressing Ctrl+S. In Blender, you need to save the file, frequently at regular intervals, to save your work.  

Now we need to repeat these steps for the two other location of the Cube at Point B and C.

Now we shall set key frame for point B.
In the Timeline Window, click on the green line using your Left Mouse Button(LMB) and drag it to frame number 120.This value is displayed on  the Current Frame Number button in the Time Line Window. We  can set the Current frame also by entering a value here. This is an alternate method to set current key frame.

Let us position the Cube at x=0,y=0,z=5, by entering these values  for location in the properties panel.

Make sure the Cube is selected, indicated by the yellow border line around the Cube. Click on "I" Button. Select "Location" in the pop-up menu. A small yellow line will be displayed at frame number 80, in the Timeline Window.

Save the File, by pressing Ctrl+S.


In the Timeline Window, click on the green line using your Left Mouse Button(LMB) and drag it to frame number 240.This value is displayed on  the Current Frame Number button in the Time Line Window. We  can set the Current frame by entering a value here. THis is an alternate method to set current key frame.

Let us position the Cube at x=0,y=0,z=0, by entering these values  for location in the properties panel.

Make sure the Cube is selected, indicated by the yellow border line around the Cube. Click on "I" Button. Select "Location" in the pop-up menu.

Save the File.


At this stage, four yellow lines must be displayed in the TimeLine Window at frame 1,120 and 240.In case you want to delete a key frame, select the key frame,with the Cursor positioned within the 3D window, press "Alt+I" key. Save the File.


STEP 4: PLAY ANIMATION

First set the current frame to frame 1 in the Timeline Window. Press Alt+A keys to play the Animation. The Cube must move from location A to B to C  and repeat the cycle.You can also press the > key, which is the play button in the Timeline Window. To stop the animation, press on the Play Button once more, or hit the "Esc" key.

This completes Part 1. Though the instruction may seem to be elaborate, it is meant to assist the first time learner. Once you get a hang of the steps, it is hardly a few minutes job.

Just play around. If some thing goes wrong, badly, start over again ! Nothing to loose.
 
 VIDEO LINK :ANIMATION USING BLENDER 2.79 PART 1 

 

VIDEO LINK : ANIMATION USING BLENDER 2.79 PART 2

 

VIDEO LINK : ANIMATION USING BLENDER 2.79 PART 3

 

VIDEO LINK : ANIMATION USING BLENDER 2.79 PART 4

 

VIDEO LINK: ANIMATION USING BLENDER 2.79 PART 5 

 

Thursday, 30 December 2021

SINE WAVES-RED,YELLOW AND BLUE SCRIPT

#THIS SCRIPT WORKS WITH BLENDER 2.8 AND ABOVE.

 import bpy
from math import sin,cos,pi

radius=100
deg=2*pi

#TO DELETE ALL EXISTING OBJECTS
bpy.ops.object.mode_set(mode='OBJECT')
bpy.ops.object.select_by_type(type='MESH')
bpy.ops.object.delete(use_global=False)


for t in range (0,360):
    
    #RED
    z=radius*sin(t*deg/360)
    x=t
    y=0
    bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
    bpy.ops.transform.resize(value=(0.9,0.9,0.9))
    obj_matl=bpy.data.materials.new("obj_clr")
    obj_matl.diffuse_color=(1,0,0,1)
    mesh=bpy.context.object.data
    mesh.materials.clear()
    mesh.materials.append(obj_matl)
    #YELLOW
    z=radius*sin(t*deg/360)
    x=t+120
    y=0
    bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
    bpy.ops.transform.resize(value=(0.9,0.9,0.9))
    obj_matl=bpy.data.materials.new("obj_clr")
    obj_matl.diffuse_color=(1,0.6,0,1)
    mesh=bpy.context.object.data
    mesh.materials.clear()
    mesh.materials.append(obj_matl)
    #BLUE
    z=radius*sin(t*deg/360)
    x=t+240
    y=0
    bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
    bpy.ops.transform.resize(value=(0.9,0.9,0.9))
    obj_matl=bpy.data.materials.new("obj_clr")
    obj_matl.diffuse_color=(0,0,1,1)
    mesh=bpy.context.object.data
    mesh.materials.clear()
    mesh.materials.append(obj_matl)

The wave form generated by the script can be seen by clicking on the link given  below:

SINE WAVE LINK 

 


   


    
   

Sunday, 26 December 2021

BPY SCRIPT TO ADD 50 CUBES AND ANIMATE THEM

In this script we add 50 cubes at random location, set random color to each cube and set key frames to each cube to animate them.

The number of cubes added can be changed by setting the range value in the first for loop.Total number of frames is set in the beginning by setting the value for the variable total_frames. Key frame interval is adjusted by setting the third variable in the range setting of the second for loop.Here it is set to 10. The diffuse color setting has four values for Red, Green, Blue and Alpha.

import bpy
from math import sin, pi
from random import randint

total_frames=100

# clear meshes in the scene
for obj in bpy.data.objects:
    if obj.type == 'MESH':
        bpy.data.objects.remove(obj)

#CREATE 10 CUBES        
for i in range (50):
    x=randint(-10,10)
    y=randint(-10,10)
    z=randint(-10,10)    
    bpy.ops.mesh.primitive_cube_add( location=(x,y,z))
    cube=bpy.context.object
    # TO ADD NEW MATERIAL TO EACH CUBE
    matl=bpy.data.materials.new("mat_clr")
    matl.diffuse_color = (x*0.6,y*0.3,z*0.1,1)
    mesh=cube.data
    mesh.materials.clear()
    mesh.materials.append(matl)
    
    # SET KEYFRAMES FOR EACH CUBE
    for frame in range(0, total_frames,10):
        bpy.context.scene.frame_set(frame)
        x=randint(-10,10)
        y=randint(-10,10)
        z=randint(-10,10)

        cube.location=(x,y,z)
        cube.keyframe_insert(data_path='location')

 

A link to the rendered video file is given below:

https://drive.google.com/file/d/1ZSFBqbky9fEUKng0ZanPFgLFlcWgkLO1/view?usp=sharing

 

Tuesday, 21 December 2021

BPY SCRIPT TO ADD MULTIPLE CUBES IN CIRCLES

This script adds multiple Cubes in concentric circles

-----------------------------------------------------------------------------------------------------------------------------
import bpy
import csv
from math import sin,cos,pi

d =pi/180 # FORMULA TO CHANGE RADIAN TO DEGREE
i=0 #  LOOP COUNTER


radius=4*1.1
x=0
y=0
z=0


for i in range (12):
  x=radius*sin(30*i*d)
  y=0
  z=radius*cos(30*i*d)
  bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=(x,y,z))
 
radius+=5

for i in range (24):
  x=radius*sin(15*i*d)
  y=0
  z=radius*cos(15*i*d)
  bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=(x,y,z))
radius+=5

for i in range (48):
  x=radius*sin(7.5*i*d)
  y=0
  z=radius*cos(7.5*i*d)
  bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=(x,y,z))
radius+=5

for i in range (96):
  x=radius*sin(3.75*i*d)
  y=0
  z=radius*cos(3.75*i*d)
  bpy.ops.mesh.primitive_cube_add(radius=1, view_align=False, enter_editmode=False, location=(x,y,z))
radius+=5

-----------------------------------------------------------------------------------------------------------------------------





BPY SCRIPT TO ADD MULTIPLE CUBES

This script must have a cube object to start with. This object is duplicated and assigned random material.

-------------------------------------------------------------------------------------------------------------------------------------------------------
import bpy
from random import randint
import random

number=100


#TO DELETE ALL EXISTING OBJECTS

bpy.ops.object.select_by_type(type='MESH')
bpy.ops.object.delete(use_global=False)

#TO ADD CAMERA
bpy.ops.object.camera_add(view_align=True, location=(0,-45,0), rotation=(1.5708,0,0))
bpy.ops.transform.resize(value=(9.42627, 9.42627, 9.42627))


#TO ADD BG PLANE
bpy.ops.mesh.primitive_plane_add( location=(0,10,0))
bpy.ops.transform.resize(value=(10, 10, 10))
bpy.ops.transform.rotate(value=-1.55203, axis=(-1, 0,0))
bpy.ops.transform.resize(value=(2,2,2))

#TO ADD MATERIAL TO PLANE
obj_matl=bpy.data.materials.new("obj_clr")
obj_matl.diffuse_color=(0,0.9,0.8)
mesh=bpy.context.object.data
mesh.materials.clear()
mesh.materials.append(obj_matl)

#TO CREATE MULTIPLE TORUS AND ASSIGN MATERIAL
for i in range(0,number):
    x=randint(-10,10)
    y=randint(-5,5)
    z=randint(-10,10)
    p=randint(1,10)
    bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
    bpy.ops.transform.resize(value=(p*0.1,p*0.1,p*0.1))
    bpy.ops.transform.rotate(value=1.5708, axis=(1, 1, 0))
    p=randint(0,9)
    #print(p)
    obj_matl=bpy.data.materials.new("obj_clr")
    obj_matl.diffuse_color=(0.8,p*0.3,0)
    mesh=bpy.context.object.data
    mesh.materials.clear()
    mesh.materials.append(obj_matl)

--------------------------------------------------------------------------------------------------------------------------------

Monday, 20 December 2021

BPY SCRIPT TO DRAW A SPIRAL

The script will draw a spiral using the cube object which is repeatedly positioned along a spiral path. The spiral is visible in the Top ortho view(7).

-----------------------------------------------------------------------------------------------------------------------------

import bpy
from math import sin,cos,pi

bigdeg=pi*2
smalldeg=pi/100
radius=2
for i in range(0,500):
    x=radius*sin(smalldeg*i)
    y=radius*cos(smalldeg*i)
    z=0
    bpy.ops.mesh.primitive_cube_add(location=(x,y,z))
    bpy.ops.transform.resize(value=(1,1,1))
    mat_red=bpy.data.materials.new("red")
    mat_red.diffuse_color=(0.8, 0, 0)
    mesh=bpy.context.object.data
    mesh.materials.clear()
    mesh.materials.append(mat_red)
    radius +=.07
 
-----------------------------------------------------------------------------------------------------------------------------

 


BPY SCRIPT TO ADD MATERIAL TO AN EXISTING OBJECT.

To run this script open blender, add a cube object and select it.Copy and paste these codes into you text editor and run it to add a material to the cube. Here Red material(color) is added to the Cube.

-------------------------------------------------------------------------------------------------------------------------------

 import bpy

mat_red=bpy.data.materials.new("red")

mat_red.diffuse_color=(0.8, 0, 0)

mesh=bpy.context.object.data

mesh.materials.clear()

mesh.materials.append(mat_red)

-------------------------------------------------------------------------------------------------------------------------------

ROUND EDGES- BEVEL TOOL

Blender version 3.6 To make any edge to be rounded smoothly, we can use the bevel tool in Edit Mode. Look at the cube in Image 1 where all t...