[Bf-committers] 3d lines patch
Johnny Matthews
johnny.matthews at gmail.com
Wed Feb 23 16:34:29 CET 2005
Here is a patch for the text editor, it allows you to create a 3d object
per each line of the text, instead of one object from the whole thing. I
needed this feature for an upcoming project, so I figured I would code it :)
The code is mainly copied from the existing to 3d object function, but
reworked for the effect I wanted.
Johnny Matthews
(guitarGeek)
-------------- next part --------------
Index: source/blender/src/editfont.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/editfont.c,v
retrieving revision 1.16
diff -u -r1.16 editfont.c
--- source/blender/src/editfont.c 22 Dec 2004 19:21:45 -0000 1.16
+++ source/blender/src/editfont.c 23 Feb 2005 15:19:26 -0000
@@ -312,6 +312,54 @@
}
+void txt_export_to_objects(struct Text *text)
+{
+ ID *id;
+ Curve *cu;
+ struct TextLine *tmp, *curline;
+ int nchars;
+
+ if(!text) return;
+
+ id = (ID *)text;
+
+ if (G.obedit && G.obedit->type==OB_FONT) return;
+ check_editmode(OB_FONT);
+
+ curline = text->lines.first;
+ while(curline){
+
+ nchars = 0;
+ add_object(OB_FONT);
+
+ base_init_from_view3d(BASACT, G.vd);
+ G.obedit= BASACT->object;
+ where_is_object(G.obedit);
+
+ cu= G.obedit->data;
+
+ cu->vfont= get_builtin_font();
+ cu->vfont->id.us++;
+
+ nchars = strlen(curline->line) + 1;
+
+ if(cu->str) MEM_freeN(cu->str);
+
+ cu->str= MEM_mallocN(nchars+4, "str");
+
+ strcpy(cu->str, curline->line);
+ cu->len= strlen(curline->line);
+ cu->pos= cu->len;
+
+ make_editText();
+ exit_editmode(1);
+
+ curline = curline->next;
+ }
+ allqueue(REDRAWVIEW3D, 0);
+}
+
+
void do_textedit(unsigned short event, short val, char _ascii)
{
Curve *cu;
Index: source/blender/src/header_text.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/header_text.c,v
retrieving revision 1.21
diff -u -r1.21 header_text.c
--- source/blender/src/header_text.c 14 Nov 2004 13:37:29 -0000 1.21
+++ source/blender/src/header_text.c 23 Feb 2005 14:54:51 -0000
@@ -275,6 +275,9 @@
case 10:
txt_export_to_object(text);
break;
+ case 11:
+ txt_export_to_objects(text);
+ break;
default:
break;
}
@@ -481,6 +484,7 @@
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Find Again|Alt F", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 9, "");
uiDefBut(block, SEPR, 0, "", 0, yco-=6, menuwidth, 6, NULL, 0.0, 0.0, 0, 0, "");
uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Convert to 3D Text|Alt M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 10, "");
+ uiDefIconTextBut(block, BUTM, 1, ICON_BLANK1, "Each Line to 3D Text|Alt M", 0, yco-=20, menuwidth, 19, NULL, 0.0, 0.0, 0, 11, "");
if(curarea->headertype==HEADERTOP) {
uiBlockSetDirection(block, UI_DOWN);
More information about the Bf-committers
mailing list