Friday, June 7, 2013

Color mesh

Introduction

Within scientific visualization we often want to show the local value of a certain parameter field as a (vertex)color. Think of a temperature distribution in 3D and a mesh which is colored so that we can assess the temperatures at the mesh locations.

Blender addon

In order to accomplish this task, we have created an addon for blender which is capable of coloring a mesh. This is done by generating or reading a 3D data field which can be sampled for a value anywhere in 3D space. The obtained value can be converted into an RGB color through our own colormap. 
So the whole process looks like this
  • For all vertices
    • Find the location
    • Get the parameter value at that location
    • Convert the value into a color
    • Assign the color to the vertex
The addon can be found here: colormesh.zip

Examples

We have used the buildin value field to put some color on Suzanne.

Simple image

To start off with: plain and simple

Animation

We have created an animation coloredSuzanne.avi in which we show some possibilities this plugin offers.

The movie is divided in different phases:
  1. We start off with suzanne shown in a box in which the original parameter field is defined. The maximum of the colormap is set very high to force all values to map to the lowest color bin
  2. After zooming in, we lower the maximum value of the color map until it reaches 3.5: the maximum value found in our data set. Suzanne is now shown as the image above
  3. Suzanne is rotated so a single vertex  changes position yielding different values and thus different colors
  4. A second rotation is made, but now the camera also rotates along, showing the change of color more clearly
  5. Suzanne is shifted through the parameter space and again colored accordingly
  6. When parts fall outside the data field, a value of 0 is assigned which results in a blue color
  7. When zooming in, the area obtaining the blue color keeps on getting bigger. Here we scale the space of the parameter field from 1 to 0.1, forcing an ever bigger part of Suzanne to be located outside the data field and hence be colored blue

Blender file

People who want to play with this example can do so using the blend file coloredSuzanna.blend we used for the animation. 
(Do not forget to install the addon ;-)

Questions

While developing this addon, two questions arose to which we don't have a clear answer
  1. Would it be possible to store data during a blender session? This addon needs to have a parameter field. It would be nice if we could store this for the course of the program; now we generate/read the data over and over again for every frame in which meshes need to be re-colored.
  2. This addon uses a python module with no blender dependence  This makes it possible to use these classes outside a blender context enabling the creation of data field files. What is the correct location for such a general python module? Now we just put it in the addons directory to ensure it is in the python path.

No comments:

Post a Comment