sábado, 16 de agosto de 2014

martes, 3 de junio de 2014

Duplicate a serie of objects in blender 2.70 with python

import bpy

# Extracted from the Bret Battey blog:Bat Hat Media

# Find the objects with the text ".A." on its name,
# make a coy of everyone,
# change the text in copy for".B.",
# and select the new objects

scene= bpy.context.scene

for n in bpy.data.objects:
    if (n.name.find(".A."))!= -1 :
        pos=n.name.find(".A.");
        newname=n.name[0:pos]+".B."+n.name[pos+3:];
        copiedobject=n;
        copiedMesh=copiedobject.data;
        mesh = bpy.data.meshes.new(newname);# Create new mesh
        ob_new = bpy.data.objects.new(newname, mesh);# Create new object associated with the mesh
     
         # Copy data block from the old object into the new object
        ob_new.data = copiedobject.data.copy();
        ob_new.scale = copiedobject.scale;
        ob_new.location = copiedobject.location;
        ob_new.rotation_euler = copiedobject.rotation_euler;

        # Link new object to the given scene and select it
        scene.objects.link(ob_new);
        ob_new.select();
     
        print (n.name," COPIED with name: ",newname);

 

jueves, 18 de abril de 2013

Modeling your Head in Blender 2.66

Hi Blenders!

This entrance in the blog is a short tutorial for demand in the  facebook's blender group, and here i`ll talk about how I did this artwork using Blender:



STEP BY STEP:

1- You need photos of your face.
       1.1 - paint ponits in your face              

    What? panit ponits in my face? are you cracy? well... surelly. But this method is sused frecuently whet you want acuare a good precision level .. or if you wont become cracy doing "punteria" positionating the vertex in side and front views of your head.


       1.2 - take photos of your Front and side views




        1.3 - erase your points.
                  Now with your cam in your hand is a good moment to clean your face and take two more photos. This will save to you a little of work erasing this point in photoshop later.


   
2- Prepare for modeling (background use)

          Now you need load your photos so that you can use it in modeling time... this is load it in the 3D view background:
                 -In  the Right tools panel of your 3DView. open the "background" tab. Then "Add" a new background and load your pointed faces in the Front and right orto views respectivelly. ( You can hit the "N" key with your mouse pointer over the 3DView if you can't see this panel)

Afer upload your photo,s surely you must scale and position them to they can correspond theirselves.
     When you finish, you should have a work area like this:

3- Modeling
  Now Is time to creativity:
               - Add a Cube
               - Add a new "Mirror" modifier.
               - Set on the property "clipping" in this modiffier
               - erase the inner plane in this cube.....
               - ........ and start to scale, subdivide, extrude, use the knife, erase or disolve planes, vertices and         edges to transform this cube in something like this:

       
   As note i say my favoutite tools:

          - Ctrl+E to extrude a plane.
           - K to use a knife to cut the faces free.
           - Select two edges of a plane and hit "subdivide" to divide that plane.
           - Ctr-R to cut multiple aligned plains.
            - Select/Edge/ Slide Edge to slide an edge along the planes it owns.
            - Shift+V to slide a vertex along the edges it owns.
            - Alt+M to join a lot of faces/edges/vertex
Be patiend, clear your mind and repose every hour. Dont be afraid to go back when you need, Restart when you wand and remember the three main words to reach the perfection : 
         
         -Observe.
         -Practice
         -Ask.
          [OPA!!!!!]

Finally, you will have got a model like this:



4- Texturing.
       
            To apply a texture in a 3D model from a 2D picture you need a way to conect them... this is known as "UV Unwrap".
            The "UV Unwrap" is a technique in which every 3D vertex in your model is asigned a 2D point in a picture.


       

              To create a UV-Unwrap with any 3D model, select it, switch to "Edit mode", select all the faces, and ... in the left "tools" panel in your 3D View.... push the "unwrap" button to open the unwrap menu. Here you got a few options for select the way blender must create a UV-Unwraped layout. (you can also hit the U key)



                If you hit now the "unwap" option, blender will decide who is the best way to covert your 3D model in a 2D net of vertex. With a structure as complex as this, the result surely will not be an useful structure. So you should help to blender cutting your model in a few edges... or as blender names them: "Seams"

                  To asign seams, you must select an egde and push the button below the unwrap button. Then it will chage its color to red.... then do it... select a serie of edges you choice and hit that button:



           Now you can create a UV-Unwrap vertex group... pushing the "Unwap" button (or hiting the U key) and selecting "Unwap" from the Unwrap menu. Once created you can observe the UV vertex group created selecting "UV Editing" from de mode menu:


                Also you can see the new vertex group created in the "vertex groups" tab in the properties panel named "UVMap":


               Now is time to create a Image and asociate it to the new UVMap created. You can do it in the uv editor... selecting Image/NEw Image... and selecting one choice (1024 x 1024, black  for example...) then create a new material with this texture, but in "coordinates" box you must select "UV" and then select "UVMap".


                       This action asign a material to your 3D Model, a texture to this material, and the image and the UVMap to this texture.
                     Now, your 3D Model has a UV Unwraped texture... but it is totally black!!! This is because the image which is asociated with it is a "New Image" totally black. Now you can get fun painting your texture with an aplication like "windows paint" or photoshop and looking its efect rendering the scene.... try it if you want.

                     Now you can paint over your model anything what you want... lines, circles, claw's paint, etcc... but ¿HOW CAN I PAINT A REAL PHOTO OVER THIS TEXTURE?

4.2- PAINTNG A UVMAP WITH ANOTHER UVMAP

              a) Create two new UV Vertex groups in the "vertex Groups" tab in the "properties panel" and name it "front" and "side"
              b) unwrap another time your object. but now selecting "proyection view" with a "front" view in your 3D Object Panel... (be sure the "active UV Map" is the one you have named "front")
              c) do it another time with the side view.



            Now you should have a object with three UV Unwrap groups: UVMap, front and side:
               d) Link each UV Map to a image: to do this.....
                      - Select the "Uv Edit" Screen layout:


                           - Select the Unwraped UVMap in the combo box and then add a new black image, this    action automatically link this UVMap to the new image created. 


                              - the front and the side uv maps are similar to this, but the image asociated to it is not a new image, instead select the photos you have taked of you face without points. for do this, select the front UV Map and open the front image, clicking in the "Image/Open Image..." menú.


                           - Now you should have a view like this


               - select al the vertices and Scale, Rotate or draG them to align them to your photo:


                     - do the same with the "side" view:


                         Now you have your three UV Maps asociated with three Images.

                  e) Now you are prepared to your Unwraped UVMap with the front and side UV maps. This work will be done in Texture mode:
           
                          - Change to default Screen layout.


                           - Change to texture mode.


                         - Now in the texture mode tools panel, select the proper brush... this is the "clone brush"


                           - Select the stencil UVMap an "Clone from UV map: side"


                                - Now start paint:


                     With this technique, you can paint one, two or more photos to a single UVMap. Combine the front and the side UV maps to create a full textured object like this:



5- A final touch.
 
                    Now is time to be creative and give freedom to the artist you have inside. Feel free to ad helmet, hair, or enythig you can imagine to put the final point to your artwork.



- THE END -