2011-02-22 10:33:14 +00:00
|
|
|
/*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** BEGIN GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
2008-04-16 22:40:48 +00:00
|
|
|
* of the License, or (at your option) any later version.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
2010-02-12 13:34:04 +00:00
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2002-10-12 11:37:38 +00:00
|
|
|
*
|
|
|
|
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* The Original Code is: all of this file.
|
|
|
|
*
|
|
|
|
* Contributor(s): none yet.
|
|
|
|
*
|
2008-04-16 22:40:48 +00:00
|
|
|
* ***** END GPL LICENSE BLOCK *****
|
2002-10-12 11:37:38 +00:00
|
|
|
*/
|
2011-02-22 10:33:14 +00:00
|
|
|
|
|
|
|
/** \file KX_Scene.h
|
|
|
|
* \ingroup ketsji
|
|
|
|
*/
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#ifndef __KX_SCENE_H
|
|
|
|
#define __KX_SCENE_H
|
|
|
|
|
|
|
|
|
|
|
|
#include "KX_PhysicsEngineEnums.h"
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <set>
|
2008-02-15 23:12:03 +00:00
|
|
|
#include <list>
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-05-06 20:18:42 +00:00
|
|
|
#include "CTR_Map.h"
|
|
|
|
#include "CTR_HashedPtr.h"
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "SG_IObject.h"
|
|
|
|
#include "SCA_IScene.h"
|
|
|
|
#include "MT_Transform.h"
|
2009-06-08 20:08:19 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
#include "RAS_FramingManager.h"
|
|
|
|
#include "RAS_Rect.h"
|
|
|
|
|
2010-04-23 22:48:26 +00:00
|
|
|
|
2004-06-07 11:03:12 +00:00
|
|
|
#include "PyObjectPlus.h"
|
2010-03-03 06:38:47 +00:00
|
|
|
#include "RAS_2DFilterManager.h"
|
2004-06-07 11:03:12 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* @section Forward declarations
|
|
|
|
*/
|
|
|
|
struct SM_MaterialProps;
|
|
|
|
struct SM_ShapeProps;
|
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
|
|
|
struct Scene;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2011-05-06 20:18:42 +00:00
|
|
|
class CTR_HashedPtr;
|
2002-10-12 11:37:38 +00:00
|
|
|
class CListValue;
|
2004-06-26 09:15:41 +00:00
|
|
|
class CValue;
|
2002-10-12 11:37:38 +00:00
|
|
|
class SCA_LogicManager;
|
|
|
|
class SCA_KeyboardManager;
|
|
|
|
class SCA_TimeEventManager;
|
|
|
|
class SCA_MouseManager;
|
2004-06-26 09:15:41 +00:00
|
|
|
class SCA_ISystem;
|
|
|
|
class SCA_IInputDevice;
|
2002-10-12 11:37:38 +00:00
|
|
|
class NG_NetworkDeviceInterface;
|
|
|
|
class NG_NetworkScene;
|
2004-06-26 09:15:41 +00:00
|
|
|
class SG_IObject;
|
2002-10-12 11:37:38 +00:00
|
|
|
class SG_Node;
|
2004-05-16 12:52:30 +00:00
|
|
|
class SG_Tree;
|
2004-06-26 09:15:41 +00:00
|
|
|
class KX_WorldInfo;
|
2002-10-12 11:37:38 +00:00
|
|
|
class KX_Camera;
|
|
|
|
class KX_GameObject;
|
2004-06-26 09:15:41 +00:00
|
|
|
class KX_LightObject;
|
|
|
|
class RAS_BucketManager;
|
2002-10-12 11:37:38 +00:00
|
|
|
class RAS_MaterialBucket;
|
|
|
|
class RAS_IPolyMaterial;
|
|
|
|
class RAS_IRasterizer;
|
|
|
|
class RAS_IRenderTools;
|
2005-01-23 01:36:29 +00:00
|
|
|
class SCA_JoystickManager;
|
2008-03-01 19:46:50 +00:00
|
|
|
class btCollisionShape;
|
2008-03-09 21:42:03 +00:00
|
|
|
class KX_BlenderSceneConverter;
|
2009-04-20 15:06:46 +00:00
|
|
|
struct KX_ClientObjectInfo;
|
2010-06-04 23:29:49 +00:00
|
|
|
class KX_ObstacleSimulation;
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2010-06-06 01:15:44 +00:00
|
|
|
#ifdef WITH_CXX_GUARDEDALLOC
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
#endif
|
|
|
|
|
2009-11-15 23:58:56 +00:00
|
|
|
/* for ID freeing */
|
|
|
|
#define IS_TAGGED(_id) ((_id) && (((ID *)_id)->flag & LIB_DOIT))
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* The KX_Scene holds all data for an independent scene. It relates
|
|
|
|
* KX_Objects to the specific objects in the modules.
|
|
|
|
* */
|
2004-06-26 09:15:41 +00:00
|
|
|
class KX_Scene : public PyObjectPlus, public SCA_IScene
|
2002-10-12 11:37:38 +00:00
|
|
|
{
|
2011-11-06 01:39:36 +00:00
|
|
|
Py_Header
|
2009-09-29 21:42:40 +00:00
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-08-25 13:43:21 +00:00
|
|
|
PyObject* m_attr_dict;
|
2009-11-22 14:42:22 +00:00
|
|
|
PyObject* m_draw_call_pre;
|
|
|
|
PyObject* m_draw_call_post;
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
2009-04-20 15:06:46 +00:00
|
|
|
|
|
|
|
struct CullingInfo {
|
|
|
|
int m_layer;
|
|
|
|
CullingInfo(int layer) : m_layer(layer) {}
|
|
|
|
};
|
|
|
|
|
2004-05-16 12:52:30 +00:00
|
|
|
protected:
|
2002-10-12 11:37:38 +00:00
|
|
|
RAS_BucketManager* m_bucketmanager;
|
|
|
|
CListValue* m_tempObjectList;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The list of objects which have been removed during the
|
|
|
|
* course of one frame. They are actually destroyed in
|
|
|
|
* LogicEndFrame() via a call to RemoveObject().
|
|
|
|
*/
|
|
|
|
CListValue* m_euthanasyobjects;
|
|
|
|
|
|
|
|
CListValue* m_objectlist;
|
|
|
|
CListValue* m_parentlist; // all 'root' parents
|
|
|
|
CListValue* m_lightlist;
|
2008-03-01 19:46:50 +00:00
|
|
|
CListValue* m_inactivelist; // all objects that are not in the active layer
|
2011-09-03 20:48:47 +00:00
|
|
|
CListValue* m_animatedlist; // all animated objects
|
2009-06-08 20:08:19 +00:00
|
|
|
|
|
|
|
SG_QList m_sghead; // list of nodes that needs scenegraph update
|
|
|
|
// the Dlist is not object that must be updated
|
|
|
|
// the Qlist is for objects that needs to be rescheduled
|
|
|
|
// for updates after udpate is over (slow parent, bone parent)
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2004-05-16 12:52:30 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* The set of cameras for this scene
|
|
|
|
*/
|
2008-02-15 23:12:03 +00:00
|
|
|
list<class KX_Camera*> m_cameras;
|
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
|
|
|
|
|
|
|
/**
|
|
|
|
* The set of fonts for this scene
|
|
|
|
*/
|
|
|
|
list<class KX_FontObject*> m_fonts;
|
|
|
|
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Various SCA managers used by the scene
|
|
|
|
*/
|
|
|
|
SCA_LogicManager* m_logicmgr;
|
|
|
|
SCA_KeyboardManager* m_keyboardmgr;
|
|
|
|
SCA_MouseManager* m_mousemgr;
|
|
|
|
SCA_TimeEventManager* m_timemgr;
|
|
|
|
|
2008-03-09 21:42:03 +00:00
|
|
|
// Scene converter where many scene entities are registered
|
|
|
|
// Used to deregister objects that are deleted
|
|
|
|
class KX_BlenderSceneConverter* m_sceneConverter;
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* physics engine abstraction
|
|
|
|
*/
|
2005-03-25 10:33:39 +00:00
|
|
|
//e_PhysicsEngine m_physicsEngine; //who needs this ?
|
2002-10-12 11:37:38 +00:00
|
|
|
class PHY_IPhysicsEnvironment* m_physicsEnvironment;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Does this scene clear the z-buffer?
|
|
|
|
*/
|
|
|
|
bool m_isclearingZbuffer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The name of the scene
|
|
|
|
*/
|
|
|
|
STR_String m_sceneName;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* stores the worldsettings for a scene
|
|
|
|
*/
|
|
|
|
KX_WorldInfo* m_worldinfo;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @section Different scenes, linked to ketsji scene
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Network scene.
|
|
|
|
*/
|
|
|
|
NG_NetworkDeviceInterface* m_networkDeviceInterface;
|
|
|
|
NG_NetworkScene* m_networkScene;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A temoprary variable used to parent objects together on
|
|
|
|
* replication. Don't get confused by the name it is not
|
|
|
|
* the scene's root node!
|
|
|
|
*/
|
|
|
|
SG_Node* m_rootnode;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The active camera for the scene
|
|
|
|
*/
|
|
|
|
KX_Camera* m_active_camera;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Another temporary variable outstaying its welcome
|
|
|
|
* used in AddReplicaObject to map game objects to their
|
|
|
|
* replicas so pointers can be updated.
|
|
|
|
*/
|
2011-05-06 20:18:42 +00:00
|
|
|
CTR_Map <CTR_HashedPtr, void*> m_map_gameobject_to_replica;
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Another temporary variable outstaying its welcome
|
|
|
|
* used in AddReplicaObject to keep a record of all added
|
|
|
|
* objects. Logic can only be updated when all objects
|
|
|
|
* have been updated. This stores a list of the new objects.
|
|
|
|
*/
|
|
|
|
std::vector<KX_GameObject*> m_logicHierarchicalGameObjects;
|
|
|
|
|
2008-07-18 19:56:56 +00:00
|
|
|
/**
|
|
|
|
* This temporary variable will contain the list of
|
|
|
|
* object that can be added during group instantiation.
|
|
|
|
* objects outside this list will not be added (can
|
|
|
|
* happen with children that are outside the group).
|
|
|
|
* Used in AddReplicaObject. If the list is empty, it
|
|
|
|
* means don't care.
|
|
|
|
*/
|
|
|
|
std::set<CValue*> m_groupGameObjects;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Pointer to system variable passed in in constructor
|
|
|
|
* only used in constructor so we do not need to keep it
|
|
|
|
* around in this class.
|
|
|
|
*/
|
|
|
|
|
|
|
|
SCA_ISystem* m_kxsystem;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The execution priority of replicated object actuators?
|
|
|
|
*/
|
|
|
|
int m_ueberExecutionPriority;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Activity 'bubble' settings :
|
|
|
|
* Suspend (freeze) the entire scene.
|
|
|
|
*/
|
|
|
|
bool m_suspend;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Radius in Manhattan distance of the box for activity culling.
|
|
|
|
*/
|
|
|
|
float m_activity_box_radius;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Toggle to enable or disable activity culling.
|
|
|
|
*/
|
|
|
|
bool m_activity_culling;
|
2004-05-16 12:52:30 +00:00
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
/**
|
|
|
|
* Toggle to enable or disable culling via DBVT broadphase of Bullet.
|
|
|
|
*/
|
|
|
|
bool m_dbvt_culling;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Occlusion culling resolution
|
|
|
|
*/
|
|
|
|
int m_dbvt_occlusion_res;
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* The framing settings used by this scene
|
|
|
|
*/
|
|
|
|
|
|
|
|
RAS_FrameSettings m_frame_settings;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This scenes viewport into the game engine
|
|
|
|
* canvas.Maintained externally, initially [0,0] -> [0,0]
|
|
|
|
*/
|
|
|
|
RAS_Rect m_viewport;
|
|
|
|
|
2004-07-17 05:28:23 +00:00
|
|
|
/**
|
|
|
|
* Visibility testing functions.
|
|
|
|
*/
|
2008-07-10 12:47:20 +00:00
|
|
|
void MarkVisible(SG_Tree *node, RAS_IRasterizer* rasty, KX_Camera*cam,int layer=0);
|
|
|
|
void MarkSubTreeVisible(SG_Tree *node, RAS_IRasterizer* rasty, bool visible, KX_Camera*cam,int layer=0);
|
|
|
|
void MarkVisible(RAS_IRasterizer* rasty, KX_GameObject* gameobj, KX_Camera*cam, int layer=0);
|
2009-04-20 15:06:46 +00:00
|
|
|
static void PhysicsCullingCallback(KX_ClientObjectInfo* objectInfo, void* cullingInfo);
|
2005-12-18 19:10:26 +00:00
|
|
|
|
|
|
|
double m_suspendedtime;
|
|
|
|
double m_suspendeddelta;
|
2004-05-16 12:52:30 +00:00
|
|
|
|
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
|
|
|
struct Scene* m_blenderScene;
|
|
|
|
|
2010-03-03 06:38:47 +00:00
|
|
|
RAS_2DFilterManager m_filtermanager;
|
2010-05-19 01:42:17 +00:00
|
|
|
|
2010-06-04 23:29:49 +00:00
|
|
|
KX_ObstacleSimulation* m_obstacleSimulation;
|
|
|
|
|
2009-08-25 13:43:21 +00:00
|
|
|
public:
|
2002-10-12 11:37:38 +00:00
|
|
|
KX_Scene(class SCA_IInputDevice* keyboarddevice,
|
|
|
|
class SCA_IInputDevice* mousedevice,
|
|
|
|
class NG_NetworkDeviceInterface* ndi,
|
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
|
|
|
const STR_String& scenename,
|
2010-04-23 22:48:26 +00:00
|
|
|
struct Scene* scene,
|
|
|
|
class RAS_ICanvas* canvas);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
virtual
|
|
|
|
~KX_Scene();
|
|
|
|
|
|
|
|
RAS_BucketManager* GetBucketManager();
|
2008-03-23 23:12:40 +00:00
|
|
|
RAS_MaterialBucket* FindBucket(RAS_IPolyMaterial* polymat, bool &bucketCreated);
|
2002-10-12 11:37:38 +00:00
|
|
|
void RenderBuckets(const MT_Transform& cameratransform,
|
|
|
|
RAS_IRasterizer* rasty,
|
|
|
|
RAS_IRenderTools* rendertools);
|
2009-11-22 14:42:22 +00:00
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Update all transforms according to the scenegraph.
|
|
|
|
*/
|
2009-06-08 20:08:19 +00:00
|
|
|
static bool KX_ScenegraphUpdateFunc(SG_IObject* node,void* gameobj,void* scene);
|
|
|
|
static bool KX_ScenegraphRescheduleFunc(SG_IObject* node,void* gameobj,void* scene);
|
2002-10-12 11:37:38 +00:00
|
|
|
void UpdateParents(double curtime);
|
2008-07-15 20:05:23 +00:00
|
|
|
void DupliGroupRecurse(CValue* gameobj, int level);
|
2008-07-18 19:56:56 +00:00
|
|
|
bool IsObjectInGroup(CValue* gameobj)
|
|
|
|
{
|
|
|
|
return (m_groupGameObjects.empty() ||
|
|
|
|
m_groupGameObjects.find(gameobj) != m_groupGameObjects.end());
|
|
|
|
}
|
2002-10-12 11:37:38 +00:00
|
|
|
SCA_IObject* AddReplicaObject(CValue* gameobj,
|
|
|
|
CValue* locationobj,
|
|
|
|
int lifespan=0);
|
|
|
|
KX_GameObject* AddNodeReplicaObject(SG_IObject* node,
|
|
|
|
CValue* gameobj);
|
|
|
|
void RemoveNodeDestructObject(SG_IObject* node,
|
|
|
|
CValue* gameobj);
|
|
|
|
void RemoveObject(CValue* gameobj);
|
|
|
|
void DelayedRemoveObject(CValue* gameobj);
|
2006-05-22 21:03:43 +00:00
|
|
|
|
2008-03-09 21:51:38 +00:00
|
|
|
int NewRemoveObject(CValue* gameobj);
|
2002-10-12 11:37:38 +00:00
|
|
|
void ReplaceMesh(CValue* gameobj,
|
2009-07-26 01:32:37 +00:00
|
|
|
void* meshob, bool use_gfx, bool use_phys);
|
2011-09-03 20:48:47 +00:00
|
|
|
|
|
|
|
void AddAnimatedObject(CValue* gameobj);
|
|
|
|
void RemoveAnimatedObject(CValue* gameobj);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* @section Logic stuff
|
|
|
|
* Initiate an update of the logic system.
|
|
|
|
*/
|
2004-10-16 11:41:50 +00:00
|
|
|
void LogicBeginFrame(double curtime);
|
|
|
|
void LogicUpdateFrame(double curtime, bool frame);
|
2011-07-14 07:03:33 +00:00
|
|
|
void UpdateAnimations(double curtime);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
LogicEndFrame(
|
|
|
|
);
|
|
|
|
|
|
|
|
CListValue*
|
2009-11-15 23:58:56 +00:00
|
|
|
GetTempObjectList(
|
|
|
|
);
|
|
|
|
|
|
|
|
CListValue*
|
2002-10-12 11:37:38 +00:00
|
|
|
GetObjectList(
|
2008-03-01 19:46:50 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CListValue*
|
|
|
|
GetInactiveList(
|
2002-10-12 11:37:38 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
CListValue*
|
|
|
|
GetRootParentList(
|
|
|
|
);
|
|
|
|
|
|
|
|
CListValue*
|
|
|
|
GetLightList(
|
|
|
|
);
|
|
|
|
|
|
|
|
SCA_LogicManager*
|
|
|
|
GetLogicManager(
|
|
|
|
);
|
|
|
|
|
|
|
|
SCA_TimeEventManager*
|
|
|
|
GetTimeEventManager(
|
|
|
|
);
|
|
|
|
|
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
|
|
|
/** Font Routines */
|
|
|
|
|
|
|
|
list<class KX_FontObject*>*
|
|
|
|
GetFonts(
|
|
|
|
);
|
|
|
|
|
|
|
|
/** Find a font in the scene by pointer. */
|
|
|
|
KX_FontObject*
|
|
|
|
FindFont(
|
|
|
|
KX_FontObject*
|
|
|
|
);
|
|
|
|
|
|
|
|
/** Add a camera to this scene. */
|
|
|
|
void
|
|
|
|
AddFont(
|
|
|
|
KX_FontObject*
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
/** Camera Routines */
|
|
|
|
|
2008-02-15 23:12:03 +00:00
|
|
|
list<class KX_Camera*>*
|
2006-01-06 03:46:54 +00:00
|
|
|
GetCameras(
|
|
|
|
);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/** Find a camera in the scene by pointer. */
|
|
|
|
KX_Camera*
|
|
|
|
FindCamera(
|
|
|
|
KX_Camera*
|
|
|
|
);
|
|
|
|
|
|
|
|
/** Find a scene in the scene by name. */
|
|
|
|
KX_Camera*
|
|
|
|
FindCamera(
|
|
|
|
STR_String&
|
|
|
|
);
|
|
|
|
|
|
|
|
/** Add a camera to this scene. */
|
|
|
|
void
|
|
|
|
AddCamera(
|
|
|
|
KX_Camera*
|
|
|
|
);
|
|
|
|
|
|
|
|
/** Find the currently active camera. */
|
|
|
|
KX_Camera*
|
|
|
|
GetActiveCamera(
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set this camera to be the active camera in the scene. If the
|
|
|
|
* camera is not present in the camera list, it will be added
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
SetActiveCamera(
|
|
|
|
class KX_Camera*
|
|
|
|
);
|
|
|
|
|
2008-02-15 23:12:03 +00:00
|
|
|
/**
|
|
|
|
* Move this camera to the end of the list so that it is rendered last.
|
|
|
|
* If the camera is not on the list, it will be added
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SetCameraOnTop(
|
|
|
|
class KX_Camera*
|
|
|
|
);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
/**
|
|
|
|
* Activates new desired canvas width set at design time.
|
|
|
|
* @param width The new desired width.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SetCanvasDesignWidth(
|
|
|
|
unsigned int width
|
|
|
|
);
|
|
|
|
/**
|
|
|
|
* Activates new desired canvas height set at design time.
|
|
|
|
* @param width The new desired height.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
SetCanvasDesignHeight(
|
|
|
|
unsigned int height
|
|
|
|
);
|
|
|
|
/**
|
|
|
|
* Returns the current desired canvas width set at design time.
|
|
|
|
* @return The desired width.
|
|
|
|
*/
|
|
|
|
unsigned int
|
|
|
|
GetCanvasDesignWidth(
|
|
|
|
void
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the current desired canvas height set at design time.
|
|
|
|
* @return The desired height.
|
|
|
|
*/
|
|
|
|
unsigned int
|
|
|
|
GetCanvasDesignHeight(
|
|
|
|
void
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the framing options for this scene
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
SetFramingType(
|
|
|
|
RAS_FrameSettings & frame_settings
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return a const reference to the framing
|
|
|
|
* type set by the above call.
|
|
|
|
* The contents are not guarenteed to be sensible
|
|
|
|
* if you don't call the above function.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const
|
|
|
|
RAS_FrameSettings &
|
|
|
|
GetFramingType(
|
|
|
|
) const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store the current scene's viewport on the
|
|
|
|
* game engine canvas.
|
|
|
|
*/
|
|
|
|
void SetSceneViewport(const RAS_Rect &viewport);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the current scene's viewport on the
|
|
|
|
* game engine canvas. This maintained
|
|
|
|
* externally in KX_GameEngine
|
|
|
|
*/
|
|
|
|
const RAS_Rect& GetSceneViewport() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @section Accessors to different scenes of this scene
|
|
|
|
*/
|
|
|
|
void SetNetworkDeviceInterface(NG_NetworkDeviceInterface* newInterface);
|
|
|
|
void SetNetworkScene(NG_NetworkScene *newScene);
|
|
|
|
void SetWorldInfo(class KX_WorldInfo* wi);
|
|
|
|
KX_WorldInfo* GetWorldInfo();
|
2008-07-10 12:47:20 +00:00
|
|
|
void CalculateVisibleMeshes(RAS_IRasterizer* rasty, KX_Camera *cam, int layer=0);
|
2002-10-12 11:37:38 +00:00
|
|
|
void UpdateMeshTransformations();
|
|
|
|
KX_Camera* GetpCamera();
|
|
|
|
NG_NetworkDeviceInterface* GetNetworkDeviceInterface();
|
|
|
|
NG_NetworkScene* GetNetworkScene();
|
2009-11-15 23:58:56 +00:00
|
|
|
KX_BlenderSceneConverter *GetSceneConverter() { return m_sceneConverter; }
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Replicate the logic bricks associated to this object.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void ReplicateLogic(class KX_GameObject* newobj);
|
|
|
|
static SG_Callbacks m_callbacks;
|
|
|
|
|
|
|
|
const STR_String& GetName();
|
|
|
|
|
|
|
|
// Suspend the entire scene.
|
|
|
|
void Suspend();
|
|
|
|
|
|
|
|
// Resume a suspended scene.
|
|
|
|
void Resume();
|
|
|
|
|
|
|
|
// Update the activity box settings for objects in this scene, if needed.
|
|
|
|
void UpdateObjectActivity(void);
|
|
|
|
|
|
|
|
// Enable/disable activity culling.
|
|
|
|
void SetActivityCulling(bool b);
|
|
|
|
|
|
|
|
// Set the radius of the activity culling box.
|
|
|
|
void SetActivityCullingRadius(float f);
|
|
|
|
bool IsSuspended();
|
|
|
|
bool IsClearingZBuffer();
|
|
|
|
void EnableZBufferClearing(bool isclearingZbuffer);
|
2009-04-20 15:06:46 +00:00
|
|
|
// use of DBVT tree for camera culling
|
|
|
|
void SetDbvtCulling(bool b) { m_dbvt_culling = b; };
|
|
|
|
bool GetDbvtCulling() { return m_dbvt_culling; };
|
|
|
|
void SetDbvtOcclusionRes(int i) { m_dbvt_occlusion_res = i; };
|
|
|
|
int GetDbvtOcclusionRes() { return m_dbvt_occlusion_res; };
|
2002-10-12 11:37:38 +00:00
|
|
|
|
2008-03-09 21:42:03 +00:00
|
|
|
void SetSceneConverter(class KX_BlenderSceneConverter* sceneConverter);
|
|
|
|
|
2002-10-12 11:37:38 +00:00
|
|
|
class PHY_IPhysicsEnvironment* GetPhysicsEnvironment()
|
|
|
|
{
|
|
|
|
return m_physicsEnvironment;
|
|
|
|
}
|
|
|
|
|
2004-03-22 22:02:18 +00:00
|
|
|
void SetPhysicsEnvironment(class PHY_IPhysicsEnvironment* physEnv);
|
2002-10-12 11:37:38 +00:00
|
|
|
|
|
|
|
void SetGravity(const MT_Vector3& gravity);
|
2011-07-14 07:03:33 +00:00
|
|
|
|
|
|
|
short GetAnimationFPS();
|
2004-05-16 12:52:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the node tree for this scene.
|
|
|
|
*/
|
|
|
|
void SetNodeTree(SG_Tree* root);
|
|
|
|
|
2010-03-03 06:38:47 +00:00
|
|
|
/**
|
|
|
|
* 2D Filters
|
|
|
|
*/
|
|
|
|
void Update2DFilter(vector<STR_String>& propNames, void* gameObj, RAS_2DFilterManager::RAS_2DFILTER_MODE filtermode, int pass, STR_String& text);
|
|
|
|
void Render2DFilters(RAS_ICanvas* canvas);
|
|
|
|
|
2010-06-04 23:29:49 +00:00
|
|
|
KX_ObstacleSimulation* GetObstacleSimulation() {return m_obstacleSimulation;};
|
|
|
|
|
2010-10-31 04:11:39 +00:00
|
|
|
#ifdef WITH_PYTHON
|
2009-08-25 22:51:18 +00:00
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
/* Python interface ---------------------------------------------------- */
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
2009-02-28 22:25:23 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_Scene, addObject);
|
2010-01-30 18:23:13 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_Scene, end);
|
|
|
|
KX_PYMETHOD_DOC(KX_Scene, restart);
|
|
|
|
KX_PYMETHOD_DOC(KX_Scene, replace);
|
2010-03-28 20:50:20 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_Scene, suspend);
|
|
|
|
KX_PYMETHOD_DOC(KX_Scene, resume);
|
2009-08-25 13:43:21 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_Scene, get);
|
2010-06-10 00:19:06 +00:00
|
|
|
KX_PYMETHOD_DOC(KX_Scene, drawObstacleSimulation);
|
2004-05-16 12:52:30 +00:00
|
|
|
|
|
|
|
|
2009-04-20 15:06:46 +00:00
|
|
|
/* attributes */
|
|
|
|
static PyObject* pyattr_get_name(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static PyObject* pyattr_get_objects(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
2009-06-08 20:08:19 +00:00
|
|
|
static PyObject* pyattr_get_objects_inactive(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static PyObject* pyattr_get_lights(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static PyObject* pyattr_get_cameras(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
2009-04-20 15:06:46 +00:00
|
|
|
static PyObject* pyattr_get_active_camera(void* self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
2009-06-08 20:08:19 +00:00
|
|
|
static int pyattr_set_active_camera(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-11-22 14:42:22 +00:00
|
|
|
static PyObject* pyattr_get_drawing_callback_pre(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_drawing_callback_pre(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
|
|
|
static PyObject* pyattr_get_drawing_callback_post(void *self_v, const KX_PYATTRIBUTE_DEF *attrdef);
|
|
|
|
static int pyattr_set_drawing_callback_post(void *selv_v, const KX_PYATTRIBUTE_DEF *attrdef, PyObject *value);
|
2009-04-20 15:06:46 +00:00
|
|
|
|
2009-06-29 02:25:54 +00:00
|
|
|
virtual PyObject* py_repr(void) { return PyUnicode_FromString(GetName().ReadPtr()); }
|
2009-08-25 13:43:21 +00:00
|
|
|
|
|
|
|
/* getitem/setitem */
|
|
|
|
static PyMappingMethods Mapping;
|
|
|
|
static PySequenceMethods Sequence;
|
|
|
|
|
2010-03-23 21:37:02 +00:00
|
|
|
/**
|
|
|
|
* Run the registered python drawing functions.
|
|
|
|
*/
|
|
|
|
void RunDrawingCallbacks(PyObject* cb_list);
|
|
|
|
|
2009-11-22 14:42:22 +00:00
|
|
|
PyObject* GetPreDrawCB() { return m_draw_call_pre; };
|
|
|
|
PyObject* GetPostDrawCB() { return m_draw_call_post; };
|
2009-09-29 21:42:40 +00:00
|
|
|
#endif
|
|
|
|
|
2005-12-18 19:10:26 +00:00
|
|
|
/**
|
|
|
|
* Sets the time the scene was suspended
|
|
|
|
*/
|
|
|
|
void setSuspendedTime(double suspendedtime);
|
|
|
|
/**
|
|
|
|
* Returns the "curtime" the scene was suspended
|
|
|
|
*/
|
|
|
|
double getSuspendedTime();
|
|
|
|
/**
|
|
|
|
* Sets the difference between the local time of the scene (when it
|
|
|
|
* was running and not suspended) and the "curtime"
|
|
|
|
*/
|
|
|
|
void setSuspendedDelta(double suspendeddelta);
|
|
|
|
/**
|
|
|
|
* Returns the difference between the local time of the scene (when it
|
|
|
|
* was running and not suspended) and the "curtime"
|
|
|
|
*/
|
|
|
|
double getSuspendedDelta();
|
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
|
|
|
/**
|
|
|
|
* Returns the Blender scene this was made from
|
|
|
|
*/
|
|
|
|
struct Scene *GetBlenderScene() { return m_blenderScene; }
|
2009-11-15 23:58:56 +00:00
|
|
|
|
|
|
|
bool MergeScene(KX_Scene *other);
|
|
|
|
|
|
|
|
|
|
|
|
//void PrintStats(int verbose_level) {
|
|
|
|
// m_bucketmanager->PrintStats(verbose_level)
|
|
|
|
//}
|
2002-10-12 11:37:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<KX_Scene*> KX_SceneList;
|
|
|
|
|
|
|
|
#endif //__KX_SCENE_H
|
|
|
|
|