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.
I think that’s most useful for scripting people. Thanks alot, i did not know the 2.4x version. Certainly nice to have!
Very interesting to see you using BGL! Can it draw images in the 3d view allready, do you know about that? I was not aware the BGL is working in at all yet in 2.5, nice
The reason I rewrote the script is that I need it for other scripts I want to develop, so it’s indeed mainly meant for developers. Normal users of Blender really don’t have a need for knowing what the index of a vertex is.
Drawing in the 3d view was only added three days ago (by Campbell in his free time, thanks a lot! :)). As far as I know you should be able to draw images as well, but it’ll be a bit harder than in 2.4 as you’ll have to use native opengl commands (no more shortcuts like Draw.Image() in 2.4).
mandoragon: I already linked to it in the first post. Here it is again.
I’ve also made a slight change to the script for Blender 2.5, so here is Index Visualiser 2.1.
It includes a minor speed increase. Written and tested for svn 27407 (it needs a pretty recent build).
The buttons are actually added to an existing panel (which is called Display), so I can’t change the name of the existing panel.
I’m glad the tool was useful to you though.
The script has been in Blender Contrib for some time now. This means that it is kept up to date with all changes in Blender and can even be automatically included when you build Blender yourself.
Practically this means that you can always find the most recent version of the script, at this link.
Fantastico! I have been thinking about CAD and how to possibly like show the angle between two edges selected in 3D view, or the length of an edge, etc. Seeing just the screenshot lets me know it can be done. I love how one idea spawns another.
Great work here, i’m just learning a lot with all your marvellous scripts !
Small Improvement: Script doesn’t keep in mind weather vertex/edge/face is hidden, so it always show index numbers although you have used “H” key to hide some vertexs.
line 68 modified: added “not v.hidden” and parenthesis.
for v in me.verts:
if not v.hidden and (v.selected or not bpy.context.scene.display_sel_only):
locs.append([1.0, 1.0, 1.0, v.index, v.co.copy().resize4D()])
Is there any reason it shouldn’t be done?
Thank you very much for your work !
PS: English is not my native language, sure you noticed :evilgrin: