Monday, April 19, 2010

BGE Real Time Text in Blender 249.2


This is a tutorial for how to create real time text in Blender 3D's Game Engine.

The video below covers the basic steps to create the Real Time Text.

The information under the video adds key commands and background information.
(It adds the "Why" for many of the steps taken)





Window Setup:

User Preferences Window
Outliner Window
3D View Window
UV/Image Editor Window
Buttons Window

See Video for window pane setup.




Step 1:
Set Viewport shading to Textured
Menu Command or Action
3D View Window -> Viewport Shading -> Textured

Corresponding Key Command
Alt-Z
(Textured/Shaded toggle)

Background Info.
This view mode renders the text on the plane so you can see It as you work in Blender.



Step 2:
Delete Cube
Menu Command or Action
(With cube selected)
3D View Window -> Object -> Delete (Erase Selected Objects?) -> Yes

Corresponding Key Command
X

Background Info.
The cube is usually already selected when you open Blender with the user default settings.



Step 3:
Create Plane
Menu Command or Action
User Preferences Window -> Add -> Mesh -> Plane



Step 4:
Bring in BGE's arialbd.tga or other BGE font image file

4 Sub 1 of 2
Menu Command or Action
UV/Image Editor Window -> Image -> Open

Corresponding Key Command
Alt-O
(With mouse over UV/Image Editor window)

Important Note
If you don't have one of these image files here is a link in the Background Info.

Background Info.
Here is the link to a .zip of the .blend and the image file used in this tutorial:

Link at Ziddu (gives 1/10 of 1 cent kickback per download):

Same link but at MediaFire (no kickback with softer ads):

If you tried the Ziddu link and didn't like it, please post your experience. I will consider removing that link.

Same for the MediaFire link as well.

If you have suggestions for where to put this file for downloading or for improvements to this Tutorial or the Video,

please post.

Thank you


4 Sub 2 of 2
Menu Command or Action
Navigate to folder with BGE's arialbd.tga font image file and click "Open Image" Button.

Background Info.
BGE will use this image to create each character of the text string you enter later in this tutorial.



Step 5:
Go Into Edit Mode for Plane
Menu Command or Action
3D View Window -> Mode Menu -> Edit Mode (while plane is selected)

Corresponding Key Command
Tab
(Edit Mode/Object Mode toggle)
(while plane is selected)

Background Info.
Make sure all 4 corners of the plane are selected while in edit mode (press "A" a few times until they're all

selected).



Step 6:
Unwrap plane flat for image placing
Menu Command or Action
3D View Window -> Mesh -> UV Unwrap -> Unwrap

Corresponding Key Command
U
(Must be in Edit Mode)

Background Info.
This option basically unfolds a 3D object about parting lines that you can create on a 3D object so it knows where to

split it. The unfolded (more accurately, unwrapped) resulting shape (or shapes depending on how you place your parting

lines) of the object is then laid flat in the UV/Image Editor window as a selection grid over the image. You can

further manipulate the shape and location of this grid over the image while seeing how the image looks on the 3D

object.





Since we are using a simple plane, there is no need for parting lines. The plane's simple square shape is laid flat

over the image for resizing as you will see in step "8".





But you still have to do the unwrap command to get the selection grid representation of the plane to be generated over

the image in the UV/Image Editor window.



Step 7:
Set up texture face visibility options

7 Sub 1 of 6
Menu Command or Action
Buttons Window -> Editing Button

Corresponding Key Command
F9


7 Sub 2 of 6
Menu Command or Action
Select "Texture Face" Tab


7 Sub 3 of 6
Menu Command or Action
Select "Tex" Button

Background Info.
Renders face of plane with texture.


7 Sub 4 of 6
Menu Command or Action
Select "Twoside" Button

Background Info.
Renders both sides of plane face.


7 Sub 5 of 6
Menu Command or Action
Select "Text" Button

Background Info.
Enables bitmaped text on face (Text on face will change to match the string you type in).


7 Sub 6 of 6
Menu Command or Action
Select "Alpha" Button

Background Info.
It's a matter of choice. It changes the visual appearance of the text image on the plane. This option has a nice

transparency to it. You can experiment with the other buttons on the bottom row.



Step 8:
In UV/Image Editor, resize the unwrapped, selected plane, representation to be

around the @ symbol in the upper left hand corner.

8 Sub 1 of 7
Menu Command or Action
Right click near lower right point to select it.

Important Note
If you make a mistake during selection and mess up the shape of the selection grid so that

it's not square any more just do the unwrap command in step "6" again and start the selection over.
(You won't have to do step "7" again either. Those settings will stay.)


8 Sub 2 of 7
Menu Command or Action
Hold shift and right click near lower left point to have both points selected.


8 Sub 3 of 7
Menu Command or Action
UV/Image Editor Window -> UVs -> Transform -> Grab/Move

Corresponding Key Command
G
(With mouse over UV/Image Editor window)


8 Sub 4 of 7
Menu Command or Action
Press the "Y" key to restrict to vertical movement.


8 Sub 5 of 7
Menu Command or Action
Left Click to place.


8 Sub 6 of 7
Menu Command or Action
Do the same for the other 3 sides but use "X" key for horizontal movement restriction.


8 Sub 7 of 7
Menu Command or Action
Pan/Zoom in "UV/Image Editor" Window as needed (same as Pan/Zoom in "3D View" Window)

Corresponding Key Command
Alt (Pan)
Alt-Ctrl (Zoom)
(With mouse over UV/Image Editor window)



Step 9:
Setup BGE (Blender Game Engine) Property

9 Sub 1 of 5
Menu Command or Action
Buttons Window -> Logic Button

Corresponding Key Command
F4


9 Sub 2 of 5
Menu Command or Action
Click Add Property Button


9 Sub 3 of 5
Menu Command or Action
Change Property Type field from "Float" to "String".

Background Info.
This is just for purpose of this tutorial.
All Property Types will work.


9 Sub 4 of 5
Menu Command or Action
Spell name in Name field "Exactly" like this (without quotes) "Text" The "T" (and only the

"T") must be Capitalized for BGE to recognize the property.


9 Sub 5 of 5
Menu Command or Action
Type anything in the next text field.



Step 10:
Exit the Edit Mode of the plane to see the text in the 3D View Window.
Menu Command or Action
3D View Window -> Mode Menu -> Object Mode

Corresponding Key Command
Tab

Important Note
Note: If your text correctly flows from left to right but the letters are upside down (as

mine always are), follow the next step to correct it. Otherwise skip over this step.



Step 11:
Correct text flow by rotating UV/Image Editor unwrapped selection window 180

degrees.

11 Sub 1 of 5
Menu Command or Action
3D View Window -> Mode Menu -> Edit Mode (while plane is selected)

Corresponding Key Command
Tab
(while plane is selected)


11 Sub 2 of 5
Menu Command or Action
With the mouse in UV/Image Editor Window, Press the "A" key until all 4 corners of the

unwrapped selection window are selected.

Corresponding Key Command
A
(Select All)


11 Sub 3 of 5
Menu Command or Action
UV/Image Editor Window -> UVs -> Transform -> Rotate

Corresponding Key Command
R
(With mouse over UV/Image Editor window)


11 Sub 4 of 5
Menu Command or Action
Hold the "Ctrl" while rotating to move in 5 degree increments


11 Sub 5 of 5
Menu Command or Action
Still holding the "Ctrl" key, Left click to place.



Step 12:
Exit the Edit Mode of the plane to see the text in the 3D View Window.
Menu Command or Action
3D View Window -> Mode Menu -> Object Mode

Corresponding Key Command
Tab



Step 13:
Start Game to see text in game mode
Menu Command or Action
User Preferences Window -> Game -> Start Game

Corresponding Key Command
P



Step 14:
Exit Game
Menu Command or Action
"Esc" Key.

Corresponding Key Command
Esc



Step 15:
Change BGE text property from string to timer and go back into game mode.

15 Sub 1 of 2
Menu Command or Action
Buttons Window -> Logic Button

Corresponding Key Command
F4


15 Sub 2 of 2
Menu Command or Action
Change Property Type field from "String" to "Timer".



Step 16:
Start Game to see timer in game mode
Menu Command or Action
User Preferences Window -> Game -> Start Game

Corresponding Key Command
P



Step 17:
Exit Game
Menu Command or Action
"Esc" Key.

Corresponding Key Command
Esc



Step 18:
To change the text color in game, add and setup material and texture

properties.

18 Sub 1 of 5
Menu Command or Action
Buttons Window -> Shading Button

Corresponding Key Command
F5


18 Sub 2 of 5
Menu Command or Action
Select "Material" (2nd) Secondary Button


18 Sub 3 of 5
Menu Command or Action
On the "Links and Pipeline" Tab, under "Link to Object," Click the "Add New" Button.


18 Sub 4 of 5
Menu Command or Action
Then on the "Texture" Tab, click "Add New" there also.


18 Sub 5 of 5
Menu Command or Action
On the "Material" Tab, change the diffuse (top) color to any color.



Step 19:
Restart Game to see Text Color.
Menu Command or Action
User Preferences Window -> Game -> Start Game

Corresponding Key Command
P



Step 20:
Exit Game
Menu Command or Action
"Esc" Key.

Corresponding Key Command
Esc



Done!!!

1 comment:

Anonymous said...

Finally!! Some Blender instruction that I can FOLLOW, and make WORK! Thank you so much! Too bad you haven't written any more after this and the peg game, as your style and attention to DETAIL is VERY helpful, and deserves to be EMULATED! GOOD JOB!!