added options to add mesh (cap ends, radius and depth)

This commit is contained in:
Campbell Barton
2007-03-28 15:25:07 +00:00
parent f5b919e12e
commit 273ca449d3
4 changed files with 37 additions and 33 deletions

View File

@@ -69,7 +69,7 @@ extern void separate_material(void);
/* ******************* editmesh_add.c */
extern void make_prim(int type, float imat[3][3], int tot, int seg,
int subdiv, float dia, float d, int ext, int fill,
float cent[3]);
float cent[3] );
extern void add_primitiveMesh(int type);
extern void adduplicate_mesh(void);
extern void add_click_mesh(void);

View File

@@ -1159,6 +1159,9 @@ void add_primitiveMesh(int type)
totoud= tot; /* store, and restore when cube/plane */
dia= G.vd->grid;
d= G.vd->grid;
/* ext==extrudeflag, tot==amount of vertices in basis */
switch(type) {
case 0: /* plane */
@@ -1178,37 +1181,41 @@ void add_primitiveMesh(int type)
undostr="Add Cube";
break;
case 4: /* circle */
add_numbut(0, NUM|INT, "Vertices:", 3, 500, &tot, NULL);
if (!(do_clever_numbuts("Circle Resolution", 1, REDRAW))) return;
ext= 0;
fill= 0;
add_numbut(0, NUM|INT, "Vertices:", 3, 500, &tot, NULL);
add_numbut(1, NUM|FLO, "Radius:", 0.001*G.vd->grid, 100*G.vd->grid, &dia, NULL);
add_numbut(2, TOG|INT, "Fill", 0, 0, &(fill), NULL);
if (!(do_clever_numbuts("Add Circle", 3, REDRAW))) return;
ext= 0;
newob = confirm_objectExists( &me, mat );
if(newob) name = "Circle";
undostr="Add Circle";
break;
case 5: /* cylinder */
add_numbut(0, NUM|INT, "Vertices:", 2, 500, &tot, NULL);
if (!(do_clever_numbuts("Cylinder Resolution", 1, REDRAW))) return;
ext= 1;
fill= 1;
d*=2;
add_numbut(0, NUM|INT, "Vertices:", 2, 500, &tot, NULL);
add_numbut(1, NUM|FLO, "Radius:", 0.001*G.vd->grid, 100*G.vd->grid, &dia, NULL);
add_numbut(2, NUM|FLO, "Depth:", 0.001*G.vd->grid, 100*G.vd->grid, &d, NULL);
add_numbut(3, TOG|INT, "Cap Ends", 0, 0, &(fill), NULL);
if (!(do_clever_numbuts("Add Cylinder", 4, REDRAW))) return;
ext= 1;
d/=2;
newob = confirm_objectExists( &me, mat );
if(newob) name = "Cylinder";
undostr="Add Cylinder";
break;
case 6: /* tube */
add_numbut(0, NUM|INT, "Vertices:", 2, 500, &tot, NULL);
if (!(do_clever_numbuts("Tube Resolution", 1, REDRAW))) return;
ext= 1;
fill= 0;
newob = confirm_objectExists( &me, mat );
if(newob) name = "Tube";
undostr="Add Tube";
break;
case 7: /* cone */
add_numbut(0, NUM|INT, "Vertices:", 2, 500, &tot, NULL);
if (!(do_clever_numbuts("Cone Resolution", 1, REDRAW))) return;
ext= 0;
fill= 1;
d*=2;
add_numbut(0, NUM|INT, "Vertices:", 2, 500, &tot, NULL);
add_numbut(1, NUM|FLO, "Radius:", 0.001*G.vd->grid, 100*G.vd->grid, &dia, NULL);
add_numbut(2, NUM|FLO, "Depth:", 0.001*G.vd->grid, 100*G.vd->grid, &d, NULL);
add_numbut(3, TOG|INT, "Cap Ends", 0, 0, &(fill), NULL);
if (!(do_clever_numbuts("Add Cone", 4, REDRAW))) return;
d/=2;
ext= 0;
newob = confirm_objectExists( &me, mat );
if(newob) name = "Cone";
undostr="Add Cone";
@@ -1216,7 +1223,7 @@ void add_primitiveMesh(int type)
case 10: /* grid */
add_numbut(0, NUM|INT, "X res:", 3, 1000, &tot, NULL);
add_numbut(1, NUM|INT, "Y res:", 3, 1000, &seg, NULL);
if (!(do_clever_numbuts("Grid Size", 2, REDRAW))) return;
if (!(do_clever_numbuts("Add Grid", 2, REDRAW))) return;
newob = confirm_objectExists( &me, mat );
if(newob) name = "Grid";
undostr="Add Grid";
@@ -1224,15 +1231,18 @@ void add_primitiveMesh(int type)
case 11: /* UVsphere */
add_numbut(0, NUM|INT, "Segments:", 3, 500, &seg, NULL);
add_numbut(1, NUM|INT, "Rings:", 3, 500, &tot, NULL);
if (!(do_clever_numbuts("UV Sphere", 2, REDRAW))) return;
add_numbut(2, NUM|FLO, "Radius:", 0.001*G.vd->grid, 100*G.vd->grid, &dia, NULL);
if (!(do_clever_numbuts("Add UV Sphere", 3, REDRAW))) return;
newob = confirm_objectExists( &me, mat );
if(newob) name = "Sphere";
undostr="Add UV Sphere";
break;
case 12: /* Icosphere */
add_numbut(1, NUM|INT, "Subdivision:", 3, 500, &subdiv, NULL);
if (!(do_clever_numbuts("Ico Sphere", 2, REDRAW))) return;
add_numbut(0, NUM|INT, "Subdivision:", 3, 500, &subdiv, NULL);
add_numbut(1, NUM|FLO, "Radius:", 0.001*G.vd->grid, 100*G.vd->grid, &dia, NULL);
if (!(do_clever_numbuts("Add Ico Sphere", 2, REDRAW))) return;
newob = confirm_objectExists( &me, mat );
if(newob) name = "Sphere";
@@ -1252,7 +1262,8 @@ void add_primitiveMesh(int type)
rename_id((ID *)G.obedit, name );
rename_id((ID *)me, name );
}
d = -d;
curs= give_cursor();
VECCOPY(cent, curs);
cent[0]-= G.obedit->obmat[3][0];
@@ -1263,12 +1274,11 @@ void add_primitiveMesh(int type)
Mat3MulVecfl(imat, cent);
Mat3MulMat3(cmat, imat, mat);
Mat3Inv(imat,cmat);
dia= G.vd->grid;
if(type == 0 || type == 1) /* plane, cube (diameter of 1.41 makes it unit size) */
dia *= sqrt(2.0);
d= -G.vd->grid;
phid= 2*M_PI/tot;
phi= .25*M_PI;

View File

@@ -1033,10 +1033,6 @@ void do_info_add_meshmenu(void *arg, int event)
/* Cylinder */
add_primitiveMesh(5);
break;
case 6:
/* Tube */
add_primitiveMesh(6);
break;
case 7:
/* Cone */
add_primitiveMesh(7);
@@ -1070,7 +1066,6 @@ static uiBlock *info_add_meshmenu(void *arg_unused)
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "UVsphere", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 3, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "IcoSphere|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 4, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cylinder|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 5, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Tube|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 6, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Cone|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 7, "");
uiDefIconTextBut(block, SEPR, 0, ICON_BLANK1, "", 0, yco-=6, 160, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Grid|", 0, yco-=20, 160, 19, NULL, 0.0, 0.0, 1, 8, "");

View File

@@ -1417,7 +1417,6 @@ static TBitem addmenu_mesh[]= {
{ 0, "UVsphere", 3, NULL},
{ 0, "Icosphere", 4, NULL},
{ 0, "Cylinder", 5, NULL},
{ 0, "Tube", 6, NULL},
{ 0, "Cone", 7, NULL},
{ 0, "SEPR", 0, NULL},
{ 0, "Grid", 8, NULL},