Navigation


RSS : Articles / Comments


PV3D Text Primitive

11:55 AM, Posted by Jim Foley, 5 Comments

Click Here to view the example

I'd never tried to use 3D Text from within Papervision until recently. Suprisingly it was a little more difficult than I expected. One hurdle was that I wanted to use my own custom font. Little did I know I had to download a seperate swf that builds a 'motif' ActionScript file. On top of that, not all characters are supported within the motif so you have to program in which characters to are allowed (FYI, I skipped that for the most part).
In the example below I added a KeyboardEvent Listener to the stage and passed in the key (that was typed) into the 3D Text object. I set up the font 'Eurostile' to be used as my custom font. When you type, it shows your message in 3D.
To make custom font motif's:
Download the file FIVe3D_make_typograph_v2.0.zip from here: http://code.google.com/p/five3d/downloads/list
Extract the file 'Make a new typography file.swf' out of the zip and copy it to this location on your PC computer (not sure where it goes on a mac):
Settings\{USERNAME}\Local Settings\Application Data\Adobe\Flash CS3\en\Configuration\WindowSWF
Once you have it installed, restart or open Flash. Make a new AS3 Fla File and save it somewhere. Then, from the menus select Window > Other Panels > Make new typography file.
Follow the instructions from the window that opens and when you're done hit the "Generate the typography file". It will then place an ActionScript file in the same location as where your .FLA resides.
Open the new ActionScript file and make sure that the class declaration 'extends Font3D'. So it should read:
public class MyCustomFontName extends Font3D
Paste in these additional functions:
override public function get motifs():Object{if(!__initialized)initialize();return __motifs;}override public function get widths():Object{if(!__initialized)initialize();return __widths;}override public function get height():Number{if(!__initialized)initialize();return __heightS;}
To use custom font motif's:
To use them is pretty simple. When you instantiate your Text3D object you'll need to simply create a new instance of your motif ActionScript class and pass it into the second parameter for the Text3D object, for example:
private var text:Text3D = new Text3D("Type Something...", new MyCustomFontMotif, myText3DMaterial);
Hopefully that will help you get through it. If you have troubles jump into the forum, make a post and I'll help ya troubleshoot any problems.
Example: Click Here
Flex Source: Click Here
Flash Source: Click Here //Note: You'll need to test the published .swf file for the code to function correctly (it won't work correctly if you do a 'control+enter' in flash).

5 Comments

Barliesque @ March 22, 2009 8:55 PM

Hey Jim, thanks for another great tutorial!

I'm having some problems getting beyond the tutorial to take control of my 3D text... I'd like to be able to"
1) Change the font size
2) Get the dimensions of the 3D text object
3) Text3D has an alpha property... which does nothing. What do I gotta do?

Many thanks!

Jim Foley @ March 24, 2009 12:29 AM

Hrrmmmmm, good questions. Sorry I didn't catch your comment earlier. If you post your questions in the Mad Vertices forum I'd catch it sooner. I usually check it three-four times a day.

I'll look into this tomorrow (its 1:27am at the moment. I need to get some sleep). Will catch up with you tomorrow mang.

Barliesque @ March 24, 2009 1:00 PM

Yeah, I thought a moment to late the forum might be a better place for that post. So, here's a link to the topic in the forum:

http://madvertices.yuku.com/topic/31/master/1/

Marie @ August 18, 2009 8:35 AM

Can't see the example - the link is broken?

lulu @ January 22, 2010 7:19 AM

Thanks for the Clear description.

override public function get ....
__heightS;

Where S should be small case.

Nice one. it worked.