2004-05-16 13:07:20 +00:00
|
|
|
#!/usr/bin/python
|
2004-03-22 22:02:18 +00:00
|
|
|
import sys
|
|
|
|
|
2006-02-04 14:15:10 +00:00
|
|
|
Import ('env')
|
|
|
|
|
|
|
|
sources = env.Glob('*.cpp')
|
2009-11-21 20:36:03 +00:00
|
|
|
defs = [ 'GLEW_STATIC' ]
|
2006-02-04 14:15:10 +00:00
|
|
|
|
2011-07-15 04:01:47 +00:00
|
|
|
incs = '. #source/blender/python/generic' # Only for bpy_internal_import.h, be very careful
|
|
|
|
incs += ' #source/blender/python/mathutils' # Only for mathutils, be very careful
|
2008-08-05 09:35:46 +00:00
|
|
|
|
2011-05-06 20:18:42 +00:00
|
|
|
incs += ' #intern/string #intern/guardedalloc #intern/container'
|
2009-05-05 23:10:32 +00:00
|
|
|
incs += ' #source/gameengine/Rasterizer/RAS_OpenGLRasterizer'
|
2011-08-07 11:54:58 +00:00
|
|
|
incs += ' #intern/audaspace/intern #intern/audaspace/FX #source/gameengine/Converter'
|
2006-02-04 14:15:10 +00:00
|
|
|
incs += ' #source/gameengine/BlenderRoutines #source/blender/imbuf #intern/moto/include'
|
Patch:[#25163] BGE support for Blender Font objects - unicode support
Problem/Bug:
------------
There were no way to have proper unicode characters (e.g. Japanese) in Blender Game Engine. Now we can :)
You can see a sample here: http://blog.mikepan.com/multi-language-support-in-blender/
Functionality Explanation:
--------------------------
This patch converts the Blender Font Objects to a new BGE type: KX_FontObject
This object inherits KX_GameObject.cpp and has the following properties:
- text (the text of the object)
- size (taken from the Blender object, usually is 1.0)
- resolution (1.0 by default, maybe not really needed, but at least for debugging/the time being it's nice to have)
The way we deal with linked objects is different than Blender. In Blender the text and size are a property of the Text databock. Therefore linked objects necessarily share the same text (and size, although the size of the object datablock affects that too). In BGE they are stored and accessed per object. Without that it would be problematic to have addObject adding texts that don't share the same data.
Known problems/limitations/ToDo:
--------------------------------
1) support for packed font and the <builtin>
2) figure why some fonts are displayed in a different size in 3DView/BGE (BLF)
3) investigate some glitches I see some times
4) support for multiline
5) support for more Blender Font Object options (text aligment, text boxes, ...)
[1] Diego (bdiego) evantually will help on that. For the time being we are using the "default" (ui) font to replace the <builtin>.
[2] but not all of them. I need to cross check who is calculating the size/dpi in/correctly - Blender or BLF. (e.g. fonts that work well - MS Gothic)
[3] I think this may be related to the resolution we are drawing the font
[4] It can't/will not be handled inside BFL. So the way I see it is to implement a mini text library/api that works as a middlelayer between the drawing step and BLF.
So instead of:
BLF_draw(fontid, (char *)text, strlen(text));
We would do:
MAGIC_ROUTINE_IM_NOT_BLF_draw(fontir, (char *)text, styleflag, width, height);
[5] don't hold your breath ... but if someone wants to have fun in the holidays the (4) and (5) are part of the same problem.
Code Explanation:
-----------------
The patch should be simple to read. They are three may parts:
1) BL_BlenderDataConversion.cpp:: converts the OB_FONT object into a KX_FontObject.cpp and store it in the KX_Scene->m_fonts
2) KetsjiEngine.cpp::RenderFonts:: loop through the texts and call their internal drawing routine.
3) KX_FontObject.cpp::
a) constructor: load the font of the object, and store other values.
b) DrawText: calculate the aspect for the given size (sounds hacky but this is how blf works) and call the render routine in RenderTools
4) KX_BlenderGL.cpp (called from rendertools) ::BL_print_game_line:: Draws the text. Using the BLF API
*) In order to handle visibility of the object added with AddObject I'm adding to the m_scene.m_fonts list only the Fonts in a visible layer - unlike Cameras and Lamps where all the objects are added.
Acknowledgements:
----------------
Thanks Benoit for the review and adjustment suggestions.
Thanks Diego for the BFL expertise, patches and support (Latin community ftw)
Thanks my boss for letting me do part of this patch during work time. Good thing we are starting a project in a partnership with a Japanese Foundation and eventual will need unicode in BGE :) for more details on that - www.nereusprogram.org - let's call it the main sponsor of this "bug feature" ;)
2010-12-16 10:25:41 +00:00
|
|
|
incs += ' #source/gameengine/Ketsji #source/gameengine/Ketsji/KXNetwork #source/blender/blenlib #source/blender/blenfont'
|
2007-12-29 19:04:45 +00:00
|
|
|
incs += ' #source/blender/blenkernel #source/blender #source/blender/editors/include'
|
2011-05-27 08:45:48 +00:00
|
|
|
incs += ' #source/blender/makesdna #source/blender/makesrna #source/blender/python #source/gameengine/Rasterizer'
|
2006-02-04 14:15:10 +00:00
|
|
|
incs += ' #source/gameengine/GameLogic #source/gameengine/Expressions #source/gameengine/Network'
|
2010-10-10 07:01:56 +00:00
|
|
|
incs += ' #source/gameengine/SceneGraph #source/gameengine/Physics/common'
|
2009-06-21 16:18:38 +00:00
|
|
|
incs += ' #source/gameengine/Physics/Dummy'
|
Merge of first part of changes from the apricot branch, especially
the features that are needed to run the game. Compile tested with
scons, make, but not cmake, that seems to have an issue not related
to these changes. The changes include:
* GLSL support in the viewport and game engine, enable in the game
menu in textured draw mode.
* Synced and merged part of the duplicated blender and gameengine/
gameplayer drawing code.
* Further refactoring of game engine drawing code, especially mesh
storage changed a lot.
* Optimizations in game engine armatures to avoid recomputations.
* A python function to get the framerate estimate in game.
* An option take object color into account in materials.
* An option to restrict shadow casters to a lamp's layers.
* Increase from 10 to 18 texture slots for materials, lamps, word.
An extra texture slot shows up once the last slot is used.
* Memory limit for undo, not enabled by default yet because it
needs the .B.blend to be changed.
* Multiple undo for image painting.
* An offset for dupligroups, so not all objects in a group have to
be at the origin.
2008-09-04 20:51:28 +00:00
|
|
|
incs += ' #source/blender/misc #source/blender/blenloader #extern/glew/include #source/blender/gpu'
|
2010-09-01 21:43:22 +00:00
|
|
|
incs += ' #extern/recastnavigation/Recast/Include #extern/recastnavigation/Detour/Include'
|
2006-02-04 14:15:10 +00:00
|
|
|
|
|
|
|
incs += ' ' + env['BF_BULLET_INC']
|
2006-06-05 15:52:26 +00:00
|
|
|
incs += ' ' + env['BF_OPENGL_INC']
|
2006-02-04 14:15:10 +00:00
|
|
|
|
2008-11-11 14:14:22 +00:00
|
|
|
if env['WITH_BF_SDL']:
|
|
|
|
incs += ' ' + env['BF_SDL_INC']
|
2011-10-20 00:19:21 +00:00
|
|
|
defs.append('WITH_SDL')
|
2009-09-29 21:42:40 +00:00
|
|
|
|
|
|
|
if env['WITH_BF_PYTHON']:
|
2010-08-29 20:52:05 +00:00
|
|
|
incs += ' ' + env['BF_PYTHON_INC']
|
2010-10-31 04:11:39 +00:00
|
|
|
defs.append('WITH_PYTHON')
|
2010-02-07 14:12:39 +00:00
|
|
|
|
2010-02-07 14:59:00 +00:00
|
|
|
if env['WITH_BF_FFMPEG']:
|
2010-08-29 20:52:05 +00:00
|
|
|
defs.append('WITH_FFMPEG')
|
2011-05-27 08:45:48 +00:00
|
|
|
|
2009-09-24 22:11:35 +00:00
|
|
|
if env['OURPLATFORM'] in ('win32-vc', 'win64-vc', 'win32-mingw'):
|
2010-08-29 20:52:05 +00:00
|
|
|
if env['BF_DEBUG']:
|
|
|
|
defs.append('_DEBUG') # for Python
|
2009-02-15 23:26:00 +00:00
|
|
|
|
2010-10-08 20:39:56 +00:00
|
|
|
if env['WITH_BF_CXX_GUARDEDALLOC']:
|
|
|
|
defs.append('WITH_CXX_GUARDEDALLOC')
|
|
|
|
|
2010-10-10 07:01:56 +00:00
|
|
|
if env['WITH_BF_BULLET']:
|
|
|
|
defs.append('USE_BULLET')
|
|
|
|
incs += ' #source/gameengine/Physics/Bullet'
|
|
|
|
|
2010-11-18 11:42:05 +00:00
|
|
|
env.BlenderLib ( 'ge_logic_ketsji', sources, Split(incs), defs, libtype=['core','player'], priority=[320,45], cxx_compileflags=env['BGE_CXXFLAGS'])
|