There already was an index visualiser for Blender 2.4, but since Campbell added drawing in the 3d-view to 2.5, I ported the old code.
The script is kept up to date with the latest changes in Blender, so you need a recent build of blender to run it.
Link
You can download the script here. (This link automatically points to the most recent version, as the script is now in the contrib section of Blender)
How to install
There are two ways to get the script working in your .blend
Make it available in all blend files:
- Put the .py file you downloaded in the folder: .blender/scripts/addons
- Open Blender and go to User Preferences --> Add-Ons --> Enable Add-On (Index Visualiser)
Or just make it available in the blend file you're currently working on:
- Open the downloaded script inside Blender text editor
- Run the script once (alt+p)
How to use
- Select an object and enter Editmode (tab-key)
- Display the properties panel (N-key)
- Go to the Mesh Display tab, it helps to fold the tabs above it
- Press the 'Visualise indices button'
About the different buttons:
Visualise indices - this toggles whether the indices are shown or not (press once to activate, press again to de-activate)
Vertices / Edges / Faces - determines of which group(s) to show the indices
Selected only - If toggled, only indices of selected verts/edges/faces are shown
If you change the mesh (selection) in edit-mode, the indices won't automatically update. You'll have to tab in and out of object mode. This was done to improve the speed of the script.
Technical explanation
(outdated as of version 2.1)
At the start of this post I said I ported the old code, but that isn't true; I had to start from scratch. The main problem was getting the right view matrix. In 2.5 it is possible to draw directly in the opengl scene (POST_VIEW and PRE_VIEW), but the rotation of the text can't be influenced then. It always faces up on the world z-axis.
The solution is drawing to POST_PIXEL (text always faces out of the screen), but this requires to translate 3d-view coordinates to 2d screen coordinates. In 2.4 you could use Window.GetPerspMatrix() as part of the procedure, but in 2.5 this doesn't exist anymore. So my solution was to get 2 opengl matrices from POST_VIEW, and use them in a second callback that draws in POST_PIXEL.
All this slows down the script quite a lot, so it's recommended not to have too many indices on the screen. To slightly speed up the script I disabled automatic updating of the selected vertices. So if you change the mesh (selection) in edit-mode, you'll have to tab in and out of objectmode manually, to update the indices. If you wish to have this automatically, you can uncomment lines 36 and 37 in the script.
Bookmarks