Archive for July, 2009

Bake Texture To Vertex Color

Posted in Blender Python Scripts with tags , , , on July 9, 2009 by 4museman

Description

This script can bake UV texture into vertex color layer.
separator

Download

Download the ZIP file “texture_to_vcol.zip“.
separator

Installation

Unpack content of ZIP file to your Blender script folder (under Windows typically something like: “C:\Program Files\Blender Foundation\Blender\.blender\scripts\”) or to the user defined path specified in your Blender in User Preferences under bookmark File Paths in the text input field titled “Python:“. Run (or restart) your Blender and you’ll find the script in the Vertex Paint Scripts menu: “Paint –> Bake Texture to VColor“.

Note: It is possible to install scripts while Blender is running without the need of its restarting by extracting script files to one of the above mentioned locations and then pressing the Re-evaluation button, which you can find in user preferences under bookmark File Paths at the end of path input field labeled “Python:“. That will cause reloading of all available scripts into menus within whole Blender.
"Bake Texture To Vertex Color" in menu.
separator

Usage

Just make sure you have a texture attached to all faces in object you want to bake, enter the Vertex Paint mode (VKEY) and from Paint menu select “Bake Texture to VColor…“. And it should be done. (If not, mail me what went wrong.)
mesh of the initial model
bitmap mapped to the UV layer
colors baked from the bitmap to the Vetrex Color
separator

LOG

(+ = added, = changed, = removed)

2007-10-21 - version 0.1
+ basic functionality - The script simply works. However I don't claim that it's completely foolproof.

separator

ToDo

maybe to make it a little more secure
adding/multiplying colors (?)

Advertisements

Reshaper

Posted in Blender Python Scripts with tags , , , on July 9, 2009 by 4museman

Description

It projects all vertices of one object onto the surface of the other object. It currently works only in Global Z axis (altitudinal axis), what is just enough to make a retopology of a terrain, which was the original purpose of the script.

A small clarification

The functionality of the script itself consisting in projection of vertices of one object onto the surface of the second object according to the given direction. Blender’s own functionality of this kind normally provides a tool called “Retopo“, which has such a little drawback, that it obviously works only in screen-space resolution of the actual viewport (using data from z-buffer) so that some kind of rounding on position values happen all the time during editing, and it can lead to the massive alternations on axis, that we didn’t want to move. So, this effect become much more stronger when we shrink the object in our viewport, which can happen very easily for instance during making of vaster terrains. Then can happen for example even that, that the position numbers of many vertices in more detailed parts of the model are rounded so much, that the function “Remove Doubles” can eliminate them, because they are in fact in almost the same coordinates.

The script Reshaper, on the other hand, strictly preserve the layout of the original geometry, and in the case of projection in one axis only it really changes just one value in the position vectors of the vertices. Well, this tool is not interactive (in contrast to Retopo), but it doesn’t distort any of your new cool model the wrong way. (It cost me one whole terrain, of course :(, before I’ve found that trifle with Retopo.)
separator

Download

Download the ZIP file “reshaper.zip“.
separator

Installation

Unpack content of ZIP file to your Blender script folder (under Windows typically something like: “C:\Program Files\Blender Foundation\Blender\.blender\scripts\”) or to the user defined path specified in your Blender in User Preferences under bookmark File Paths in the text input field titled “Python:“. Run (or restart) your Blender and you’ll find the new script in menu “Object –> Scripts –> Reshaper“.

Note: It is possible to install scripts while Blender is running without the need of its restarting by extracting script files to one of the above mentioned locations and then pressing the Re-evaluation button, which you can find in user preferences under bookmark File Paths at the end of path input field labeled “Python:“. That will cause reloading of all available scripts into menus within whole Blender.
separator

Usage

First select the object, from which you want to copy the shape (object A in the picture below), then the object on which you want to apply the shape (object B in the picture below – this must be an active object in the scene, i.e. drawn or outlined with lighter color in the viewport).
Reshaper obr-2a
Then run Reshaper – “Object –> Scripts –> Reshaper“.
Reshaper obr-2b
The active object (C in the picture below) ought to change the shape according to the first object in Z axis only (vertical axis). Positions of other axis (X and Y) will remain the same.
Reshaper obr-2c
Reshaper works currently in model’s local coordinates. I assume, that it is more useful, than if it was in global coordinates. But if someone sees it differently, it can be changed easily.

This tool has a potencial to be aninteractive, however more accurate alternative for “Retopo” tool. The functionalities allowing this, are just started in the code, but remained unfinished (see the LOG bellow). If there will be someone with high demand for these functionalities (and not finish them himself), try to let me know. ;)
separator

LOG

(+ = added, = changed, = removed)

2007-11-22 - version 0.1
+ functionality "Rest to ground" - it is activated automatically by two Mesh objects in selection and the change is applied on the active object (last selected)
+ functionality "Retopo" - it is activated automatically by one Mesh object in selection and is applied on itself (because it is the active object in the same time); it takes into account all visible objects in the scene (or just objects in the same layer?) and from the current point of view receive their shape (is projected upon them) - UNFINISHED
+ functionality "Cast to direction" - it is activated automatically by three objects in selection, one Empty and two Meshes, one of them active (last selected); the change is applied on the active object, that changes its shape according to the other Mesh object in the direction of Z axis of the Empty object - UNFINISHED

separator

ToDo

it can happen sometimes, that some of the vertices doesn’t move to the right place; it occurs probably when vertex hit the edge between two faces precisely and thus doesn’t belong neither of them; a small move with a vertex in any of the objects can get you around this problem, however I think I know how to correct it in the script, so maybe some day…
finish off “Retopo” functionality perchance (?)
finish off “Cast to direction” functionality perchance (?)