|
15th July 2004, 01:34 AM | #1 |
Senior Member
Professional user
Join Date: Jul 2003
Posts: 899
|
vertex_set_point
Hi all,
I have a plugin that moves a selection "toward" a 3D point (mainly for moving a selection with higher precision than manual editing allows along a non-axis-aligned plane/edge). I perform moves at the vertex level using vertex_set_point(). The plugin works almost perfectly, but the selection bb doesn't update in the view window. Here's an example of what happens - you can see in the "Left" view where the vertices used to be, and how the selection bb didn't change: I'm calling redraw_all() at the end of the function. What am I missing? Is vertex_set_point() the preferred method of moving vertices? Thanks, Dennis |
15th July 2004, 02:50 AM | #2 |
Administrator
Professional user
Join Date: Jun 2003
Posts: 4,565
|
You need to call a couple of other functions. Normals should be recalculated and the bounding box should be remade.
Here's the actual code used for Vertex->Align-to-axis. Code:
Prototype void selected_vertices_align_to_axis(int axis) { List *vl = ac_selection_get_vertices_all(); add_undoable_vertex_positions("align vertices", vl); for (List *p = vl; p != NULL; p = p->next) { Vertex *v = (Vertex *)p->data; switch (axis) { case 0: // x v->x= 0.0; break; case 1: // y v->y = 0.0; break; case 2: // z v->z = 0.0; break; } } selected_calc_normals(); find_bounding_box(); display_message("%d vertices aligned to axis", list_count(vl)); list_free(&vl); redraw_all(); } Note that selected_calc_normals will also recalculate any subdivisions too. Andy |
15th July 2004, 10:20 AM | #3 |
Senior Member
Professional user
Join Date: Jul 2003
Posts: 899
|
I could not seem to find "find_bounding_box()" in the AC3D header file, and, of course, the compiler threw up on it.
However, adding this line to ac_plugin.h fixed it: Code:
Prototype void find_bounding_box(); Based on your comments and code, it looks like I had everything else right (although I used vertex_set_point() instead of directly setting the xyz vals). The Undoable code is *very* handy and easy-to-use once you see an example or two. Excellent work on the Undo system in AC3D! Thanks, Dennis |
15th July 2004, 11:01 AM | #4 |
Administrator
Professional user
Join Date: Jun 2003
Posts: 4,565
|
>Prototype void find_bounding_box();
Oops - how did that get missed out? :? I've put it in now... Andy |
|
|