From 5519157c86df8de08e31fe0ccf588b402ec11f30 Mon Sep 17 00:00:00 2001 From: Johnny Matthews Date: Thu, 24 Feb 2005 19:22:31 +0000 Subject: This is an initial commit for inserting a text file as one 3d text object per line. The function for making the objects aligned to the screen needs to be added, since right now it is aligning rotation to the screen but translation is not right since I am adding an offset to the non-viewport location of the objects. That offset just needs to be translated to screen first. --- source/blender/src/editfont.c | 67 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'source/blender/src/editfont.c') diff --git a/source/blender/src/editfont.c b/source/blender/src/editfont.c index fec40995a2c..2c5be982b7a 100644 --- a/source/blender/src/editfont.c +++ b/source/blender/src/editfont.c @@ -52,6 +52,7 @@ #include "DNA_vfont_types.h" #include "DNA_scene_types.h" #include "DNA_text_types.h" +#include "DNA_view3d_types.h" #include "BKE_displist.h" #include "BKE_font.h" @@ -312,6 +313,72 @@ void txt_export_to_object(struct Text *text) } +void txt_export_to_objects(struct Text *text) +{ + ID *id; + Curve *cu; + struct TextLine *tmp, *curline; + int nchars; + int linNum = 0; + + 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){ + /*skip lines with no text, but still make space for them*/ + if(curline->line[0] == '\0'){ + linNum++; + curline = curline->next; + continue; + } + + + nchars = 0; + add_object(OB_FONT); + + base_init_from_view3d(BASACT, G.vd); + G.obedit= BASACT->object; + where_is_object(G.obedit); + + + /* Do the translation */ + + G.obedit->loc[1] -= linNum; + + /* End Translation */ + + + 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); + + linNum++; + curline = curline->next; + } + allqueue(REDRAWVIEW3D, 0); +} + + void do_textedit(unsigned short event, short val, char _ascii) { Curve *cu; -- cgit v1.2.3