Anda di halaman 1dari 77

GIFT UNIVERSITY SCHOOL OF COMPUTER SCIENCE

Graduation Project

MODELING, TEXTURING, ANIMATING & 3D GAMES DEVELOPMENT IN BLENDER 3D

By

Tamour Ahmad (05108114)

Submitted in Partial Fulfillment of the Requirement of the Degree of Bachelor of Science 2009

Acknowledgement

Patience & perseverance is the part & parcel to make fulfill any desired motto successfully. Likewise we do have the pleasure to expose that I have already completed my project with grand success namely MODELING, TEXTURING, ANIMATING & 3D GAMES DEVELOPMENT IN BLENDER 3D.

I wish to thank my parents for their undivided support and interest, who has inspired me and encouraged me to go my own way, without whom I would be unable to complete this project.

I am grateful to Sir.Bhatti for his continuous support for the project, from initial advice and contacts in the early stages of conceptual inception, and through ongoing advice and encouragement to this day. I would like to call up all my faculty members whose essential guidance & whole hearted devotion really inspired us as well as helped too in the fulfillment of our desired task.

At last I want to thank Hamid who appreciated me for my work and motivated me to continue it.

Abstract

Blender is the open source software for 3D modeling, animation, rendering, postproduction, interactive creation and playback. It is available for all major operating systems under the GNU General Public License. Aimed at media professionals and artists, Blender can be used to create 3D visualization, stills as well as broadcast quality video, while the incorporation of a real-time 3D engine allows for the creation of 3D interactive content for standalone playback.

The project is to get a touch to 3D world. How things are done in 3D. Make some models, practice some animation, do some programming to make plug-ins and finally make a small model library, that library should be used to make a new bigger model.

ii

List of Figures
Figure 1 Blender 3D Windows installation (a) ................................................................. 3 Figure 2 - Blender 3D Windows installation (b) ................................................................. 4 Figure 3 - Blender book practice Window model ................................................................ 7 Figure 4 - Dining set Idea .................................................................................................... 8 Figure 5 - Dining set ............................................................................................................ 8 Figure 6 - Texture plug-in compiling commands .............................................................. 16 Figure 7 - Opening texture tab ........................................................................................... 17 Figure 8 - Selecting plug-in type ....................................................................................... 17 Figure 9 - Selecting plug-in ............................................................................................... 18 Figure 10 - Cube object with texture ................................................................................. 18 Figure 11 - Circles texture idea .......................................................................................... 19 Figure 12 - Circles texture ................................................................................................. 19 Figure 13 - Colored edges idea .......................................................................................... 20 Figure 14 - Colored Edges ................................................................................................. 20 Figure 15 - Gift Box texture............................................................................................... 21 Figure 16 - Gift Box texture idea ....................................................................................... 21 Figure 17 - Grid texture idea .............................................................................................. 22 Figure 18 - Grid texture ..................................................................................................... 22 Figure 19 - Hyperbola texture ............................................................................................ 23 Figure 20 - Hyperbola texture idea .................................................................................... 23 Figure 21 - Noise texture idea ............................................................................................ 24 Figure 22 - Noise Texture .................................................................................................. 24 Figure 23 - Blender sketch idea and implemented model.................................................. 25 Figure 24 - Plate sketch idea and implemented model ...................................................... 25 Figure 25 - Ceiling light sketch idea and implemented model .......................................... 26 Figure 26 - Chair sketch idea and implemented model ..................................................... 26 Figure 27 - Oven top sketch idea and implemented model ............................................... 27 Figure 28 - Microwave oven sketch idea and implemented model ................................... 28 Figure 29 - Refrigerator sketch idea and implemented model ........................................... 29 Figure 30 - Glass sketch idea and implemented model ..................................................... 29 Figure 31 - Stylish glass sketch idea and implemented model .......................................... 30 Figure 32 - Sink sketch idea and implemented model ....................................................... 30 Figure 33 - Oven sketch idea and implemented model...................................................... 31 Figure 34 - Pan Sketch idea and implemented model........................................................ 31 Figure 35 - Tray sketch idea and implemented model ....................................................... 32 Figure 36 - Spatula sketch idea and implemented model .................................................. 32 Figure 37 - Tea pot and cups sketch idea and implemented models ................................. 33 Figure 38 - Diner set implemented model using existing ideas ......................................... 33 Figure 39 - Vase sketch idea and implemented model ...................................................... 34 Figure 40 - Fireplace sketch idea and implemented model ............................................... 34 Figure 41 - Side table idea and implemented model.......................................................... 35 iii

Figure 42 - Cabinet idea and implemented model ............................................................. 36 Figure 43 - Table idea and implemented model ................................................................ 37 Figure 44 Object mode.................................................................................................... 43 Figure 45 - Edit mode ........................................................................................................ 43 Figure 46 - Resizing cube (A) ............................................................................................ 44 Figure 47 - Resizing cube (B) ............................................................................................ 44 Figure 48 - Table Leg (A) .................................................................................................. 45 Figure 49 Table Leg (B) ................................................................................................. 46 Figure 50 - Table Leg (C) .................................................................................................. 46 Figure 51 - Table Leg (D) .................................................................................................. 47 Figure 52 - Sub diving Table ............................................................................................. 47 Figure 53 - Selecting Vertices............................................................................................ 48 Figure 54 - Table completed .............................................................................................. 48 Figure 55 - Table Sheet (A) ............................................................................................... 49 Figure 56 - Table Sheet (B) ............................................................................................... 50 Figure 57 - Table Sheet (C) ............................................................................................... 50 Figure 58 - Table Sheet (D) ............................................................................................... 51 Figure 59 - Table Sheet (E) ................................................................................................ 51 Figure 60 - Table Sheet (F) ................................................................................................ 52 Figure 61 - Table Sheet (G) ............................................................................................... 52 Figure 62 - Table with Sheet .............................................................................................. 53 Figure 63 - Chair (A) ......................................................................................................... 53 Figure 64 - Chair (B).......................................................................................................... 54 Figure 65 - Chair (C).......................................................................................................... 54 Figure 66 - Chair (D) ......................................................................................................... 55 Figure 67 - Chair (E) .......................................................................................................... 55 Figure 68 - Chair (F) .......................................................................................................... 56 Figure 69 - Chair Leg (A) .................................................................................................. 56 Figure 70 - Selecting vertices to place legs ....................................................................... 57 Figure 71 - Leg places at the selected vertex ..................................................................... 57 Figure 72 Complete Chair ............................................................................................... 58 Figure 73 - Chair seat (A) .................................................................................................. 58 Figure 74 - Chair Seat (B) .................................................................................................. 59 Figure 75 - Chair Seat (C) .................................................................................................. 59 Figure 76 - Combined Table Chairs................................................................................... 60 Figure 77 - Plate (A) .......................................................................................................... 60 Figure 78 - Plate (B) .......................................................................................................... 61 Figure 79 - Plate (C) .......................................................................................................... 61 Figure 80 - Plate (D) .......................................................................................................... 62 Figure 81 - Spoon (A) ........................................................................................................ 62 Figure 82 - Spoon (B) ........................................................................................................ 63 Figure 83 - Spoon (C) ........................................................................................................ 63 Figure 84 - Fork (A) ........................................................................................................... 64 Figure 85 - Fork (B) ........................................................................................................... 64 iv

Figure 86 - Fork (C) ........................................................................................................... 65 Figure 87 - Fork (D) ........................................................................................................... 65 Figure 88 - Fork (E) ........................................................................................................... 66 Figure 89 - Fork (F) ........................................................................................................... 66 Figure 90 - Fork (G) ........................................................................................................... 67 Figure 91 - Combing all items ........................................................................................... 67 Figure 92 Adding Material Object .................................................................................. 68 Figure 93 Adding a texture object .................................................................................. 69 Figure 94 - Specifying texture type and loading image ..................................................... 69 Figure 95 - The final image ............................................................................................... 70

Table of Contents
Acknowledgement ................................................................................................................ i Abstract ................................................................................................................................ii Chapter 1: Introduction ........................................................................................................ 1 1.1. 1.2. 2.1. 2.2. 3.1. 3.1.1. 3.2. 4.1. 4.2. 4.4. 4.5. Modeling and Rendering: ...................................................................................... 1 Game Engine: ........................................................................................................ 1 Windows [1] ........................................................................................................... 3 Linux ..................................................................................................................... 5

Chapter 2: Blender 3D Installation ...................................................................................... 3

Chapter 3: Book Reading and Sample Material .................................................................. 6 Blender 3D: Architecture, Buildings, and Scenery (Book) ................................... 6 Book practice material ....................................................................................... 7 Blender Game Kit (Book) ..................................................................................... 9

Chapter 4: Blender Texture Plug-ins ................................................................................. 11 Introduction ......................................................................................................... 11 Syntax [2].............................................................................................................. 12 Using Plug-ins ..................................................................................................... 17 My Plug-ins ......................................................................................................... 19 Circles .......................................................................................................... 19 Colored Edges .............................................................................................. 20 Gift Box ....................................................................................................... 21 Grid .............................................................................................................. 22 Hyperbola ..................................................................................................... 23 Noise ............................................................................................................ 24

4.5.1. 4.5.2. 4.5.3. 4.5.4. 4.5.5. 4.5.6.

Chapter 5: Model Library .................................................................................................. 25 Chapter 6: Models .............................................................................................................. 38 Chapter 7: Conclusion........................................................................................................ 39 Chapter 8: References ........................................................................................................ 40 Appendix A ........................................................................................................................ 41 Appendix B ........................................................................................................................ 43

vi

Chapter 1 1. Introduction
Blender is the open source software for 3D modeling, animation, rendering, texturing and game development. It is obtainable for all major operating systems under the GNU General Public License. It is a user friendly program and can be used by a novice user to a highly professional user depending on the need and purpose.

Since it is licensed under the GNU General Public License (the GPL), anyone have the right to use Blender for any purpose, and anyone have access to the source codes and can modify the program and also can copy and distribute the program.

1.1.

Modeling and Rendering: Blender provides facilities for 3D modeling, animation, rendering,

texturing and game development. You can make models in blender using different meshes provided. You can use cubes, planes, spheres and many others to make your desired model. Models can be textured though mapping images on them or even using plug-ins which you can download and make by yourself as well. Models can be placed in light and can be made transparent or translucent in order to make the desired object. Besides still images, Blender provides facility to create movie sequences through rendered pictures of successive frames. If the output of animations after rendering are saved as *.avi *.jpeg in Blender, the *.avi file can be viewed in real player of windows operating system. Many examples of the movies are provided and can be downloaded free of cost from websites provided.

1.2.

Game Engine: A game engine is software that simulates a part of reality. Through a game

engine, you can interact with a 3-D world in real-time, controlling objects which can interact with other objects in that world. If you have ever played a video game 1

on a computer, a console or in a game arcade, you have used a game engine of some kind. The game engine is the heart of a game and consists of several parts. One part displays the 3-D world and its objects on your screen, drawing and redrawing your scenes as things change. Another part deals with decision making (known as game logic), for example, deciding when events like doors opening should occur. Another part simulates physics, such as gravity, inertia, momentum and so on. Yet another part detects when objects collide with each other, while another actually moves objects. The game engine tries to simulate all these things as quickly as possible to provide a smooth fluid simulation.

Chapter 2 2. Blender 3D Installation


2.1. Windows [1] Download the file blender-2.xx-windows.exe, from the download section of the Blender Website. Start the installation by double-clicking the file. This presents you with some questions, for which the defaults should be OK. After setup is complete, you can start Blender right away, or use the entry in the Start menu.

Figure 1 Blender 3D Windows installation (a)

The second dialog presents you with the license. You are expected to accept it if you want the installation to go any further. After accepting the license, select the components you wish to install (there is just one, Blender) and the additional actions:

Add a shortcut to the Start menu Add Blender's icon to desktop Associate .blend files with Blender

By default they are all checked. If you don't want some action to be taken, simply uncheck it. When done, click on Next. The next dialog is where to put the executable files, usually in the C:\Program Files folder.

Figure 2 - Blender 3D Windows installation (b)

The next dialog is tricky, and it is where to put user files. These folders save user data, namely temp data like test renders and physics data. Each user of that PC can have their own, or they call all share one.

Select a place to install the files to (the default should be OK), and click Next to install Blender. Press Close when installation is over.

Afterwards you will be asked whether you want to start Blender immediately. Blender is now installed and can be started by means of the Start menu (an entry named "Blender Foundation" will have been created by the setup routine) or by double-clicking a Blender file (*.blend).

After the files are unpacked, Blender will check for required system components, like DLLs, which you must get from Microsoft or your hardware vendor. Most common is a VCRT dll that is/was not bundled with old versions of Windows. After confirmation, you will be able to run Blender!

If, like many people, you are a) obsessed with Blender, and b) have a USB drive, you'll be glad to know that Blender runs beautifully off a USB key. Just download the .zip version and extract it. You may want to avoid having it store the animation output or other temporary files on the drive, as it may shorten the life, but otherwise, Blender runs fine.

If in case blender asks for python. Download the python from the official site and install python.

2.2.

Linux In Linux you just have to download blender. Extract it from the archive

and then you can run it by executing the blender file. One important note in using blender in Linux is that you should have glibc installed on your Linux. If you dont have it, you will have to install it on your system in order to run blender.

Chapter 3 3. Book Reading and Sample Material


3.1. Blender 3D: Architecture, Buildings, and Scenery (Book) This book describes Blender good enough for a beginner to get start from. He described features in the Blender and different ways of using them. He started the book with a brief introduction to Blender. Chapter one is an overview of the application, where to get from and how to install it. Chapter also gives description of the system requirements and online models repository. Chapter two is a guided tour of the Blender interface, including all of its modes like modeling, editing, rendering, and etc. Chapter three gives detailed information to some extend about the tools used to make a model. Some examples are given as well. Chapter four, five and six cover modeling in a bit detail; many examples are given, including furniture, building, glass and etc. This includes building with proper proportion and scale, making more precise adjustments, and attention to architectural particulars like symmetry and modeling rounded objects. It also includes a look at planning a project before you begin modeling objects, so that you can take better advantage of layers, level of detail, and external object libraries. Chapter seven covers the material area; materials can be applied to the object to colorize it, to give it a real look. Different techniques are given to add material to an object. Chapter eight covers a more advanced type of materialization called texturing, images are attached on the objects to make them more realistic and to add more look and feel. Chapter nine is kind of more advanced approach to texturing. Allan described how a picture can be mapped on an object to get different colors on different parts of the object. Chapters ten and eleven explore Blender's lighting system, including built-in lamps, shadows, the radiosity and ambient occlusion lighting models, and the extra options available through the external YafRay renderer. Chapter 13 explains two animation options for use after a model is complete. First, it describes how to create an animated walk-through or flythrough of a completed model suitable for use in a presentation. Second, it explains how to use Blender's game engine to create a 3-D model that users and clients can explore interactively. Finally, Chapter 14 gives basic advice on how to

post-process rendered images in the GIMP, including color correction and touching up stray rendering artifacts. Many other tools can be used instead of GIMP. Adobe photo shop is available and many other like it.

3.1.1. Book practice material

Figure 3 - Blender book practice Window model

A double hung sash window made from the practice material in book. It has metallic skeleton and a glass material in it. First of all the skeleton is given a mirror and glowing touch to make it metallic. And then the material in that skeleton is set to ray transparent to make is transparent.

Figure 4 - Dining set Idea

Figure 5 - Dining set

A dining furniture model made after practicing blender 3D modeling. The sample model contains, table, chair, table sheet, plates, spoon and fork. Some objects like floor, chair, and table sheet are textured while others are left uncolored.

3.2.

Blender Game Kit (Book) The Official Blender Game Kit is a complete guide and reference to

creating interactive 3-D animation and games with Blender. It begins with an extensive introduction to 3-D graphics, explaining basic concepts and the Blender interface. Step-by-step tutorials teach the art of creating and animating models then show how to turn them into simple games. Experienced 3-D artists will appreciate the complex game demos, character animation tutorials, introduction to Python, and advanced reference section. The included CDROM offers 10 playable and editable games that readers can use to build their own games and distribute them for free.

Game engine is the heart of the game, a composite of different modules to handle all things at a time: graphics, input, output, physics, artificial intelligence, etc. Not only providing the functionalities mentioned but also providing the facility to interact at a lower level with memory and processor.

Top companies build their own game engines to make a game or now a days companies are purchasing prebuilt game engines and then they modify it according to their game requirement. To build a game engine is a very costly thing to do investing thousands of dollars. But again modifying a game engine is not an easy task as well.

Modifying existing game is fun but only if you know the routines and all the logic used in the game. Game mods on the other hand are a great starting point, but most commercial game engines restrict distribution therefore you cannot modify a game engine.

Blender game kit takes the development of game one step ahead. Blender requires no broad programming knowledge, no custom coding, and a proven architecture for rendering quality graphics while offering management of nearly all input and output functions required for a quality gaming environment. With Blender a game can be as complex or simple as the developer chooses, therefore allowing everyone with minimal graphics experience to develop 3-D games.

Blender facilitates all the features required for a game development. Indeed, the preferences are impressive enough to allow it to compete with many commercial game engines and development suites: graphical editors, collision detection, dynamics simulation, Python scripting, scene multi-layering, overlays, game logic, artificial intelligence, physics, input, output, and 3D rendering. Graphics rendering is facilitated with a scalable OpenGL design for crossplatform portability. Unlike other OpenGL rendering engines, Blender requires no advanced programming or knowledge of OpenGL conventions. The developer only needs to focus on design of game; rest of the work is handled by blender itself with minimal user interaction.

OpenGL provides a wonderful interface to produce dramatic effects through both hardware and software accelerated rendering options. Various transparency and map models are available, including animated mapping, reflection mapping, environment mapping, halos, lens, flares, and even realistic fog. A radiosity solver is included to speed animation design, while edge rendering, oversampling, motion blurring, post-production filtering, fields, and non-square pixels are supported to deliver maximum graphics quality.

10

Chapter 4 4. Blender Texture Plug-ins


4.1. Introduction Plug-ins are software modules that add to the functionality of an application. Many applications use plug-ins, including Eudora, Photoshop, and web browsers like Firefox and Internet Explorer. Blender plug-ins are made in C. What is the purpose of a plug-in in Blender 3D? Blender uses the plug-ins for texturing. The basics behind a texture plug-in are that you are given some inputs; position, and normal values as well as some other info. Then you return intensity, color and/or normal information depending on the type of texture plug-in.

Plug-ins are supported (loaded/called) in Blender using the dlopen() family of calls. For those unfamiliar with the dlopen system it allows a program (Blender) to use a compiled object as if it were part of the program itself, similar to dynamically linked libraries, except the objects to load are determined at runtime. One disadvantage of blender plug-ins is that if the plug-in crashes so does blender.

Plug-ins are all about mathematics. You have to use extensive mathematics to make plug-ins. When you are given coordinates of a point, you have to calculate the location of the point in the graph and then according to the texture you have to fill that given point with a color. Filling with a color mean you are providing red, green and blue color, additionally you are supplying alpha value of the color made out of the RGB.

11

4.2. i.

Syntax [2] #include <plugin.h> Every Blender plug-in should include this header file, which contains all of the structures and defines needed to properly work with Blender. ii. char name[]="Tiles"; A character string containing the plug-in name, this value will be displayed for the texture's title in the Texture Buttons window. iii. #define NR_TYPES 2 char stnames[NR_TYPES][16]= {"Square", "Deformed"}; Plug-ins are allowed to have separate subtypes for minor variations on algorithms - for example the default clouds texture in Blender has the "Default" and "Color" subtypes. NR_STYPES should be defined to the number of subtypes required by your plug-in, and a name for each subtype should be given. Every plug-in should have at least 1 subtype and a subtype name. iv. VarStruct varstr[]= {...}; The varstr contains all of the information Blender needs to display buttons for a plug-in. Buttons for plug-ins can be numerical for input data, or text for comments and other information. Plug-ins are limited to a maximum of 32 variables. Each VarStruct entry consists of a type, name, range information, and a tool tip. The type defines the data type for each button entry, and the way to display the button. For number buttons this value should be a combination (ORed) of INT or FLO for the number format, and NUM, NUMSLI, or TOG, for the button type. Text buttons should have a type of LABEL. 12

The name is what will be displayed on (or beside) the button. This is limited to 15 characters. The range information consists of three floats that define the default, minimum, and maximum values for the button. For TOG buttons the minimum is set in the pressed state, and the maximum is set in the depressed state. The tip is a string that will be displayed when the mouse is over this button (if the user has tool tips on). This has a limit of 80 characters, and should be set to the NULL string ("") if unused. v. typedef struct Cast {...}; The cast structure is used in calling the doit function, and serves as a way to simply access each plugin's data values. The cast should contain, in order, an integer or float for every button defined in the varstr, including text buttons. Typically these should have the same name as the button for simple reference. vi. float result[8]; The result array is used to pass information to and receive information from the plug-in. The result values are mapped as follows: Result Index Significance result[0] result[1] result[2] result[3] result[4] result[5] result[6] result[7] Intensity value Red color value Green color value Blue color value Alpha color value Range 0.0 to 1.0 0.0 to 1.0 0.0 to 1.0 0.0 to 1.0 0.0 to 1.0

X normal displacement value -1.0 to 1.0 Y normal displacement value -1.0 to 1.0 Z normal displacement value -1.0 to 1.0

13

The plug-in should always return an intensity value. Returning RGB or a normal are optional, and should be indicated by the doit() return flag "1" (RGB) or "2" (Normal). Before the plug-in is called, Blender includes the current rendering-normal in result[5], result[6] and result[7]. vii. float cfra The cfra value is set by Blender to the current from before every render pass. This value is in the frame number +/- .5 depending on the field settings. viii. plugin_tex_doit prototype The plugin_tex_doit function should be prototyped for use by the getinfo function. You do not need to change this line. ix. plugin_tex_getversion This function must be in each plug-in for it to be loaded correctly. You should not change this function. x. plugin_but_changed This function is used to pass information about what buttons the user changes in the interface. Most plug-ins should not need to use this function, only when the interface allows the user to alter some variable that forces the plug-in to do recalculation (a random hash table for example). xi. plugin_init If needed plug-ins may use this function to initialize internal data. NOTE: This init function can be called multiple times if the same plug-in texture is copied. Do not init global data specific to a single instance of a plug-in in this function.

14

xii.

plugin_getinfo This function is used to communicate information to Blender. You should never need to change it.

xiii.

plugin_tex_doit The doit function is responsible for returning information about the

requested pixel to Blender. a. int stype This is the number of the selected subtype, see the NR_TYPES and char stypes entries above. b. Cast *cast The Cast structure which contains the plug-in data, see the Cast entry above. c. float *texvec This is a pointer to 3 floats, which are the texture coordinates for which a texture value is to be returned. d. float *dxt float *dyt If these pointers are non-NULL they point to two vectors (two arrays of three floats) that define the size of the requested texture value in pixel space. They are only non-NULL when OSA is on, and are used to calculate proper anti aliasing. The doit function should fill in the result array and return 0, 1, 2 or 3 depending on what values have been filled in. The doit function should always fill in an intensity value. If the function fills in a color value it should return 1, if it fills in a normal value it should return 2, if it fills in everything it should return 3.

15

4.3.

Compilation In order to compile a plug-in you must have lcc-win32. Lcc-win32 is a

compiler system for windows and it is free of cost. Download and install lccwin32. After installation move your C plug-in file to bin folder in the installed lccwin32 folder or set your path to bin folder in command prompt. Copy the required header file in the directory where the source file is located. The whole process is summarized below. 1. Install the free C compiler for windows called lcc-win32 2. Copy the C plug-in file to lcc-win32 bin folder or 2. In command prompt set the path to the bin folder of lcc-win32. 3. Copy following header files to the directory where source files are located documentation.h externdef.h floatpatch.h iff.h plugin.DEF plugin.h seq.def tex.def util.h

And finally when you have done all things, now it is the time to compile the plug-ins. Plug-ins are compiled in two steps. Firstly, we compile the plug-in and then we link the compiled file. The two steps are shown in the screenshot below.

Figure 6 - Texture plug-in compiling commands

16

4.4.

Using Plug-ins After you have compiled the plug-ins; you can use them in the blender.

You can apply them on any type of object. Now let us see how the plug-ins are loaded in blender and how they are used. Let us take an example of a plug-in which makes a grid like structure on an object. First of all open Blender 3D, make an object or use the default cube in the blender.

Press F6 to open texture option. Or press the buttons as shown in the screenshot below. 1 2

Figure 7 - Opening texture tab

Now in the texture type, select plug-in. It will open a new option tab having a button to allow loading for the plug-in.

Figure 8 - Selecting plug-in type

17

Figure 9 - Selecting plug-in

Now browse to the folder containing the plug-in dll and select the plug-in. As you will click the button you will see that the texture will appear in the preview box. Render the image and you will see the texture on the object you have applied.

Figure 10 - Cube object with texture

If the plug-in has some options with it, you will see those options or buttons in the plug-in option tab. A plug-in may contain buttons to set color, size, ratios, intensity, and etc. you can adjust the plug-in through those sliders or buttons.

18

4.5.

My Plug-ins I have made several plug-ins which are listed below. The plug-ins are fully

customizable and adjustable. 4.5.1. Circles In this plug-in user can increase or decrease the number of circles. The minimum number of circles is 0 which will leave the surface clean and maximum numbers of circles is 25. You can also adjust the width of the circles ranging 0 through 1. In addition, you can also change the colors of circles on each side. All the nested circles will be of same color.
Figure 11 - Circles texture idea

The equation;

plug-in the

works

on takes

circle the

algorithm

vertices from blender as an input and then calculates the pixels location by putting the value of the vertex in the equation. The result of the equation decides the color of the pixel. The plugin is implemented by nested loops to lookup the vertices of each circle and then fills the vertex with specified color. The nested loops are again then facilitated with recursive function.
Figure 12 - Circles texture

19

4.5.2. Colored Edges This plug-in permits the user to change the color of each individual corner. The same plugin can be applied to any object making a different look. The plug-in colors the body by finding center points and then coloring the object from it centre to its own corner.

Figure 13 - Colored edges idea

Figure 14 - Colored Edges

20

4.5.3. Gift Box This plug-in color the

edges of the object and from top and bottom it makes a design. The color of the edges is adjustable. Except the colors, this plug does not allow the user to change anything. It gives a very beautiful look to an object. The plug-in calculates the given data and then colors the adjacent edges.

Figure 16 - Gift Box texture idea

Figure 15 - Gift Box texture

21

4.5.4. Grid The plug-in lets the user to change the colors of lines. It also allows the user to choose the density of lines. The density ranges from 1 to 98. Choosing would leave only single lines in each coordinate of the axis. The higher you choose the density the more crowded the lines will be.

The plug-in works on the simple straight line equation; the algorithm takes the vertices from blender as an input and then calculates the pixels location by putting the value of the vertex in the equation. The result of the equation directs the color of the pixel.

Figure 17 - Grid texture idea

Figure 18 - Grid texture

22

4.5.5. Hyperbola The plug lets the user to change the colors of the hyperbolas. It also allows the user to change the number of hyperbolas. The count ranges from 0 to 25. Selecting 0 will leave the surface blank. The plug-in allows the user to change the thickness of the hyperbola. Hyperbola is dependent on two factors, the distance between two parts and the openness of both parts. They are also given; you can change their value to widen the hyperbola or to increase the distance between them.
Figure 20 - Hyperbola texture idea

The

plug-in

works

on

hyperbola equation; the algorithm takes the vertices from blender as an input and then calculates the pixels location by putting the value of the vertex in the equation. The result of the equation directs the color of the pixel. The plug-in is implemented by nested loops to lookup the vertices of each circle and then fills the vertex with specified color. The nested loops are again then facilitated with recursive function.
Figure 19 - Hyperbola texture

23

4.5.6. Noise The plug-in has only two options; whether to make the texture black and white or o use RGB colors. The plug-in works by random numbers, when a vertex is given to the plug-in it fills the vertex with randomly chosen color. In BW case it chooses randomly between black and white while in RGB case is chooses from Red, Green and Blue.
Figure 21 - Noise texture idea

Figure 22 - Noise Texture

24

Chapter 5 5. Model Library


I have made the model library for kitchen. The library contains items in the kitchen. It contains about 21 models. The screenshots of the models are shown below with their sketched ideas on the left or top.

5.1.

Blender

Figure 23 - Blender sketch idea and implemented model

User can change the colors of the blender; it has ray mirror property which makes it reflect the light.

5.2.

Plate

Figure 24 - Plate sketch idea and implemented model

User can change the colors of the blender; it has ray mirror property which makes it reflect the light. 25

5.3.

Ceiling Lamp

Figure 25 - Ceiling light sketch idea and implemented model

User can change the colors of the blender; it has ray transparency which will let it glow if a lamp or light source is placed inside.

5.4.

Chair

Figure 26 - Chair sketch idea and implemented model

User can change the colors of the chair; the legs of the chair act as mirror hence reflecting light to make them chrome painted. 26

5.5.

Oven top

Figure 27 - Oven top sketch idea and implemented model

This is stove top, it can be placed at kitchen tables or ovens. Colors could be customized but they are best matched.

27

5.6.

Microwave oven

Figure 28 - Microwave oven sketch idea and implemented model

User can change the colors of the microwave oven; it has transparency property in the glass which allows seeing inside.

28

5.7.

Refrigerator

Figure 29 - Refrigerator sketch idea and implemented model

User can change the colors of the fridge; it has ray mirror property which makes it reflect the light to make it metallic.

5.8.

Glass

Figure 30 - Glass sketch idea and implemented model

User can change the shades of the glass; it has ray transparency property which makes it refract the light to show it as a glass object.

29

5.9.

Stylish glass

Figure 31 - Stylish glass sketch idea and implemented model

User can change the shades of the glass; it has ray transparency property which makes it refract the light to show it as a glass object.

5.10. Sink

Figure 32 - Sink sketch idea and implemented model

User can change the shades of the sink; it has ray mirror property different in different parts to differentiate between sink and taps. 30

5.11. Oven

Figure 33 - Oven sketch idea and implemented model

User can change the colors of the microwave oven; it has transparency property in the glass which allows seeing inside. And it has ray mirror property in remaining parts to be visible as metallic.

5.12. Pan

Figure 34 - Pan Sketch idea and implemented model

User can change the colors of the pan; it has ray mirror property to glow in the light a bit. 31

5.13. Tray

Figure 35 - Tray sketch idea and implemented model

User can change the color of the tray. Properties can be adjusted according to the requirement.

5.14. Spatula

Figure 36 - Spatula sketch idea and implemented model

User can change the colors of the Spatula; it has mirror property in the front part which allows it to give a metallic vision.

32

5.15. Tea pot and cups

Figure 37 - Tea pot and cups sketch idea and implemented models

A set of teapot and cups, fully customizable, colors can be changed and mirror or transparent property can be applied.

5.16. Dinner set

Figure 38 - Diner set implemented model using existing ideas

A set of dining utensils, fully customizable, colors can be changed, shades can be changed and mirror or transparent property can be applied. It is made from existing ideas. 33

5.17. Vase

Figure 39 - Vase sketch idea and implemented model

User can change the color of the vase. A texture is applied on the vase to give it a muddy look.

5.18. Fireplace

Figure 40 - Fireplace sketch idea and implemented model

User can apply a wood texture onto the object or can use blender internal wood plug-in to give the fireplace a wooden look. 34

5.19. Side table

Figure 41 - Side table idea and implemented model

User can change the color of the kitchen side table from different places. Top color can be different from bottom colors. User can also change color of the handles of drawers.

35

5.20. Cabinet

Figure 42 - Cabinet idea and implemented model

User can change the colors of the cabinets. And can even place objects in the cabinet. The cabinet give a wooden look so wood texture or plug-ins can be applied.

36

5.21. Table

Figure 43 - Table idea and implemented model

User can change the color of the legs of the table and can change the shade of the glass of the table. It is made from existing ideas.

37

Chapter 6 6. Models

The model shown above has many objects in it which have been taken from the library shown in chapter 5. The model makes a kitchen. It uses lamp light in the ceiling light and area light in the middle Ceiling light. Only some of the objects are downloaded from the internet. Different object properties are used to create realistic effect. As oven has shine in it so the window mirror has. The table is transparent and the light passes through it. The ceiling glows due to the light of the bulbs and reflects the light back.

The models are duplicated; array modifiers are used for duplicating. The lights are using the same properties to ease the user; if we change any property of a single light; it will change all the lights automatically according to it. Same thing is done with the side tables. If color or texture of one table is changed all of the others will be changed accordingly. This makes work very easy instead of repetition of work.

38

Chapter 7 7. Conclusion
After doing the entire project I have learned many things. First of all the project gave a very good idea of 3D world, secondly the project delivered a good knowledge of 3D mathematics and thirdly it gave fine initiative to gaming. The project also helped us to learn how models are made in 3D applications like blender which we used, 3D max, Maya and etc. How coordinates are handled, how vertices are controlled. And then we learned about lights, how they are controlled, how radiosity and illumination is handled.

In Blender 3D we learned how to make objects, how different objects are made out of cubes and cornered objects. A circle is made up of small polygons which have sharp corners but they are so small in size that they all together make a smooth sphere.

While making plug-ins, intense mathematics was used. We learned mathematics in different angle. This time we used mathematics in real world otherwise mathematics was just a subject to study. We used different equations to draw different textures and implemented different algorithms to make different shapes on textures. It was really fun to handle coordinates in real but not just imaginary mathematics like we do in classes.

Thirdly after studying the second book I was able to use Blenders 3D engine. It is a small but much powerful engine. I made some sample games which were provided with the book CD. Creating game was fun rather than playing just buying and playing it. Game engine gave much knowledge how it works. Game engine handles everything like gravity, hit, touch, stroke and etc.

In the end I would like to say thanks to Sir.Bhatti who assigned me a really great touch. As I am also interested in the 3D field. The whole project was fun rather than a burden. I did my project whole heartedly and have put all of my efforts in completing it.

39

Chapter 8 8. References
[1] Manual/Introduction/Installing Blender - BlenderWiki March 8, 2009, from CS Research Lab: GIFT University Gujranwala. Website: http://wiki.blender.org/index.php/Doc:Manual/Introduction/Installing_Blender

[2] Writing a Texture Plug-in March 8, 2009, from CS Research Lab: GIFT University Gujranwala. Website: http://download.blender.org/documentation/htmlI/ch27s02.html

Other referred pages http://www.cs.virginia.edu/~lcc-win32/ http://en.wikipedia.org/wiki/Blender_(software) http://www.tutorialized.com/tutorials/Blender-3d/1 http://www.blender3darchitect.com/ http://www.blendernation.com/2006/02/18/the-blender-3d-modelrepository/ http://www.katorlegaz.com/3d_models/ http://e2-productions.com/repository/index.php http://www.blender.org/education-help/tutorials/tutorial-folder/3dwalkthrough/ http://www.upperfold.com/3D.shtml http://www.blender3d.it/ http://www.blenderguide.org/Blender-Resources/models-co/Blender-3DModel-Repository-akator-l36.html http://www.blender.org/download/resources/ http://www-users.cs.umn.edu/~mein/blender/plugins/ http://download.blender.org/documentation/htmlI/ch27.html http://www-users.cs.umn.edu/~mein/blender/plugins/plugindoc.html http://www-users.cs.umn.edu/~mein/blender/plugins/dll.html http://www.techimo.com/articles/index.pl?photo=60

40

Appendix A
Generic texture plug-in #include "plugin.h"

/* Texture name */ char name[24]= "";

#define NR_TYPES 3 char stnames[NR_TYPES][16]= {"Intens","Color", "Bump"}; /* Structure for buttons, * butcode name default min max 0 */

VarStruct varstr[]= { {NUM|FLO, "Const 1", 1.7, -1.0, 1.0, ""}, };

typedef struct Cast { float a; } Cast;

float result[8]; float cfra; int plugin_tex_doit(int, Cast*, float*, float*, float*);

/* Fixed Functions */ int plugin_tex_getversion(void) { return B_PLUGIN_VERSION; }

void plugin_but_changed(int but) { }

41

void plugin_init(void) { }

void plugin_getinfo(PluginInfo *info) { info->name= name; info->stypes= NR_TYPES; info->nvars= sizeof(varstr)/sizeof(VarStruct);

info->snames= stnames[0]; info->result= result; info->cfra= &cfra; info->varstr= varstr;

info->init= plugin_init; info->tex_doit= (TexDoit) plugin_tex_doit; info->callback= plugin_but_changed; }

int plugin_tex_doit(int stype, Cast *cast, float *texvec, float *dxt, float *dyt) {

if (stype == 1) { return 1; } if (stype == 2) { return 2; } return 0; }

42

Appendix B
To start making the shown furniture model, first of all start the blender. A cube will be present in the centre of the screen. First of all, let us make the flat surface of the table. Press the [Tab] key to enter into Edit mode.

Figure 44 Object mode

Figure 45 - Edit mode

43

Once you have entered the edit mode, press [Ctrl] + [Tab] keys, a menu will be displayed with three options namely Vertices, Edges and Faces. Select the Faces option from the menu or alternatively press the [3] to select the third option. Once option is select, select the face at the positive z-axis by right clicking on the centre spot of the face. Once the face is selected, press the [G] key to grab the face and then [Z] key to resize in only z-axis direction. Resize it until its height reaches to 0.500.

Figure 46 - Resizing cube (A)

Now extend the other sides of the cube until it looks like the one in the following image with specified sizes.

Figure 47 - Resizing cube (B)

44

The upper part of the table has been created. Now we have to make the legs of the table. Press [Space] on the 3D screen. Add a cylinder of radius 0.25 and depth 4. Press [Tab] to enter edit mode. In the edit mode press [Ctrl] + [R] to loop subdivide. Give it the following cuts: 1. First of all cut the cylinder at a distance of 0.010 from bottom. 2. Give it another cut at a distance of 0.250 from the previous cut. 3. Another cut at a distance of 4. Another cut at a distance of 0.250 from previous cut. 5. Now a cut at a distance of 0.010 from the top. The cylinder should look similar to the one shown in the figure below.

Figure 48 - Table Leg (A)

The purpose of these cuts will be explained later. Now as we have divided the cylinder into many parts. Now its time to give a real touch. Get back to Object mode by pressing [Tab] key. Press [F9] to open Editing panel. In the modifiers tab add modifier Sub surf. Now enter into edit mode and select the following vertices by selecting two or more vertices in a loop and then press [Ctrl] + [E]. A menu will appear, select Edge Loop Select from the menu. It will select all the vertices present in the loop as shown in the figure below.

45

Figure 49 Table Leg (B)

Enter into Scale manipulator mode by pressing [Ctrl] + [Alt] + [S]. The axis arrows will be converted into squares. Grab the y-axis outside for about 1.5 by holding [Ctrl] + [Shift]. Do the same for x-axis. Repeat these both processes for fourth loop from the bottom. Now do the same for both the loops at the bottom one by one. Finally do it once again for the second loop from the top. Following shape will be created.

Figure 50 - Table Leg (C)

46

Select the vertex at the center on the top. And press [Shift] + [S] and selectCursor Selection. Enter the object mode and click on the centre cursor from mesh tab.

Figure 51 - Table Leg (D)

Now select the upper part of the table and subdivide it like shown in the image below.

Figure 52 - Sub diving Table

47

Select one of the vertexes from the surface below and put the curser there by pressing [Shift] + [S].

Figure 53 - Selecting Vertices

Select the leg of the table and press [Shift] + [S] and this time select Selection > Cursor. The leg will move to the selection. Now select the flat part of the table and press [Shift] + [S] and select Cursor --> Selection. Once the selection cursor moves to the centre of the table select the leg and from the Mesh tap press the Center Cursor button. Now from the modifier tab; add Mirror Modifier to x-axis and y-axis. It would look like the image shown below.

Figure 54 - Table completed

48

Now the table has been created, to give a real touch, let us polish it by adding a sheet onto it. To make a sheet place the cursor the top of the table and add a mesh plane. Scale the plane with the lengths shown in the figure using [Ctrl] + [Alt] +[S] in the edit mode. Press [Ctrl] + [Tab], a menu will appear, edge all the edges one by one and extrude them by pressing [E]. Extrude for a length of 0.300. When extruding press the [X] or [Y] to extrude in specific direction. Then press and hold [Shift] to extrude. The model will look like the shown in the figure below.

Figure 55 - Table Sheet (A)

Once extruded; press [Ctrl] + [Tab] and then [2] to enter edges selection mode. Select each of the edges and drag them downward (z-axis) as shown in the figure. While dragging, press and hold [Ctrl] button and drag one step.

49

Figure 56 - Table Sheet (B)

To make the corners of the sheet, use the make face option in the blender. Press [Ctrl] + [Tab] keys and then [1] to enter into vertex selection mode. Select all the three edges and press [F] to make a new face. The example is shown in the following figure.

Figure 57 - Table Sheet (C)

Make faces of all four sides. Now subdivide the sheet into many parts as shown in figure using subdivide option. You can use sub dividing option by pressing [Ctrl] + [R] in edit mode.

50

Figure 58 - Table Sheet (D)

Now get into the edge selecting mode by pressing [Ctrl] + [Tab] and then [2] key. Select the base edge of the triangular face you created by pressing [F] key. And drag them downward in z-axis. Once done, enter into vertex mode and select vertices of side one by one. And drag them outside for a distance of about 0.300. Do this for all sides.

Figure 59 - Table Sheet (E)

51

Now add sub surf to the sheet to make it smoother. But before adding sub surf subdivide the sheet from the sides; otherwise the sheet will shrink. Well! Try it for yourself and then subdivide. Subdivide as shown below.

Figure 60 - Table Sheet (F)

We have subdivided the side from here. These are two lines with a distance of 0.001 between them.

Figure 61 - Table Sheet (G)

Take a look the picture, you will notice that the flag wood on the legs of the table is under the sheet and therefore it is not visible. Thus removing it will not affect anything. Remove the sheet to decrease the load on rendering process. 52

Figure 62 - Table with Sheet

The dining table has been created.

The chairs: Press [2] to go to next frame. Add a cube by pressing space and then select cube from the mesh menu. Enter the edit menu and press the cube downward until it reaches to height 0.200.

Figure 63 - Chair (A)

53

Extrude the face from a side to about 0.200 lengths. Extrude the extruded part upward for a length of 3.00 by pressing and holding [Ctrl] key.

Figure 64 - Chair (B)

Now subdivide the back of the chair into five parts. And select the edges of the middle rectangle. Press them inward. After that select the edges from the top of them and press them inward using scale-manipulator.

Figure 65 - Chair (C)

54

Now we have to add sub surf to make it smoother. But again, before adding sub surf use subdivide to make kind of boundaries of the chair; otherwise what will happen, check it yourself.

Figure 66 - Chair (D)

The sub-division on each side is of about .100 widths. But the place where the back and base of the chair meet, there it is having a width of about 0.001.

Figure 67 - Chair (E)

The highlighted edge is not a single one, actually these are three edges. One from the base and the other from the back. Now add sub surf. 55

Figure 68 - Chair (F)

Make legs for the chair. Add a cube from mesh objects. Resize it to a height of 2.000 unit, breadth of 0.100 unit and width of about 0.200 units. Subdivide it from the middle. Subdivide the upper part from the top and the bottom part from bottom to add sub surf modifier.

Figure 69 - Chair Leg (A)

56

Now the leg is ready. Next task is to attach it to the chair. To attach it to the chair, change its centre to the corner of the top face. To change the centre, select the top most face corner vertex of the leg and press [Shift] + [S] and then select the option Cursor --> Selection. Return to object mode and click centre cursor from the mesh tab. Now select the chair and change the mode to edit mode. Select the vertex as shown in figure. And place the cursor there.

Figure 70 - Selecting vertices to place legs

Select the leg and press [Shift] + [S] and then select Selection Cursor. Select the chair again and select the shown edge and place the cursor there.

Figure 71 - Leg places at the selected vertex

57

After the cursor has been placed; change the mode to object mode and select the leg and press the center cursor button and add Mirror modifier in Y-axis direction. Now make back legs. Select the legs and press [Shift] + [D] and then press [Y] to move the copied legs in Y-axis direction. Place them at their appropriate place as shown in figure.

Figure 72 Complete Chair

Lets add a seat to the chair. Add another cube in the scene. Resize it to height 0.300 units. And place it over the chair as shown in the picture.

Figure 73 - Chair seat (A)

58

Make its borders because we have to add sub surf modifier.

Figure 74 - Chair Seat (B)

Select the topmost face and drag a little higher in z-axis direction and add sub surf modifier.

Figure 75 - Chair Seat (C)

Now press [`] key to merge both the frames. And adjust the chair according to the position of the table. Make the copies of the chair as shown in the picture.

59

Figure 76 - Combined Table Chairs

Lets place some plates, spoons and forks on the table. Press [3] to advance to third frame. Add a sphere from the mesh menu having radius 0.25 units and depth 0.020 units. Change the mode to edit mode and selection mode to edge selection mode. Select two top border edges and then press [Ctrl] + [E]. A menu will appear, select Edge Loop Select from the menu, it will select all the edges in the line. Look at the figure below.

Figure 77 - Plate (A)

60

Press [Ctrl] + [Alt] + [S] to switch to Scale manipulator mode. First of all drag it into y-axis and then in x-axis direction equally. I dragged them until the scale reached to 1.500 which is displayed on the left while dragging something.

Figure 78 - Plate (B)

Change the mode to translate mode by pressing [Ctrl] + [Alt] + [G] and drag it a little higher.

Figure 79 - Plate (C)

Next change the selection mode to face mode and select all the faces in the curve and extrude them in z-axis direction. It will make the plate a little thicker. After extruding add sub surf modifier. 61

Figure 80 - Plate (D)

Lets make a spoon now. Add a UVsphere from the mesh menu.

Switch to edit

mode and then face selection mode. Select the faces of the sphere from the top and remove them by pressing [X] key. Remove the faces to make it as the shape shown in the picture below.

Figure 81 - Spoon (A)

Press [A] to select the vertices of the remaining sphere. And switch to Scale Manipulator Mode in Edit mode. Drag the sphere in x-axis or y-axis direction until 62

shape of the spoon is attained. After making the shape, make the spoon little thicker by extruding the faces upward as shown in picture.

Figure 82 - Spoon (B)

Select the faces of the spoon as shown in the above figure and extrude them. It will make it look like a spoon as shown in the picture below. After extruding, make it a little wider by selecting the faces at the back. And finally add sub surf modifier.

Figure 83 - Spoon (C)

63

Now lets make a fork. Add another cube in the frame. And resize it to the size shown below.

Figure 84 - Fork (A)

Extrude one of its sides and subdivide it from the middle. And extrude its sides for a length of 0.25. After extruding, extrude the faces of the new faces created individually to length of 0.020.

Figure 85 - Fork (B)

64

Separate them by selecting their faces as shown in the figure. And remember the fraction to which you separated them.

Figure 86 - Fork (C)

Now select their faces one by one and resize them as shown below through scale manipulation mode.

Figure 87 - Fork (D)

65

Now extrude these faces and then resize the faces at the end as shown below in the picture.

Figure 88 - Fork (E)

Now subdivide the regions from the middle as shown in the picture below.

Figure 89 - Fork (F)

66

Now select the faces indicated in the picture shown below and move those 0.150 units higher along the Z-axis.

Figure 90 - Fork (G)

Now add sub surf modifier to it. Press [`] key to merge all the frames. Now place all the things at their correct places. As shown below.

Figure 91 - Combing all items

67

You will be noticing the floor and the walls in the picture shown above. That is something very difficult. These are just planes. Add three planes; resize them by any method i.e. Extruding or Scaling.

Applying Textures
To give your models a real touch, to make them look like they are real we either have to paint them or another very good, efficient way is to apply textures on them. Textures are basically pictures of real objects or even designed picture which we paste on the models. Suppose you have a football and a world map. If you paste the world map on a football, wont it look like a globe? Surely it will.

With the same procedure, we will apply textures on the models. You can download texture from different sites but I recommend searching them from Google Images. Let us start applying texture on our models. Select any object from the scene, lets start from table sheet. Select it and enter the Shading mode by pressing [F5]. In the shading menu select the sub-menu Material buttons in case it is not selected by default. In the Links and Pipeline tab press the Add New button.

Figure 92 Adding Material Object

68

After you have pressed the button, a material object will be created for the table sheet. Now form the texture tab press the Add New button to add a texture object for the table sheet as shown in the picture below. Once you have pressed the button, press [F6] to enter the texture mode.

Figure 93 Adding a texture object

In the Texture tab select the texture type as Image. After selected the type as image press the Load button from the Image tab to select the image. Browse for the image to use as a texture and press the button select image.

Figure 94 - Specifying texture type and loading image

69

Now do the same for all the objects in the whole model. Apply appropriate images as their textures.

Figure 95 - The final image

70

Anda mungkin juga menyukai