Initial revision
[blender.git] / source / gameengine / Converter / KX_BlenderSceneConverter.h
1 /**
2  * $Id$
3  *
4  * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version. The Blender
10  * Foundation also sells licenses for use in proprietary software under
11  * the Blender License.  See http://www.blender.org/BL/ for information
12  * about this.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software Foundation,
21  * Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22  *
23  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
24  * All rights reserved.
25  *
26  * The Original Code is: all of this file.
27  *
28  * Contributor(s): none yet.
29  *
30  * ***** END GPL/BL DUAL LICENSE BLOCK *****
31  */
32 #ifndef __KX_BLENDERSCENECONVERTER_H
33 #define __KX_BLENDERSCENECONVERTER_H
34
35 #include "GEN_Map.h"
36
37 #include "KX_ISceneConverter.h"
38 #include "KX_HashedPtr.h"
39 #include "KX_IpoConvert.h"
40
41 class KX_WorldInfo;
42 class SCA_IActuator;
43 class SCA_IController;
44 class RAS_MeshObject;
45 class RAS_IPolyMaterial;
46 class BL_InterpolatorList;
47
48 class KX_BlenderSceneConverter : public KX_ISceneConverter
49 {
50         vector<KX_WorldInfo*>   m_worldinfos;
51         vector<RAS_IPolyMaterial*> m_polymaterials;
52         vector<RAS_MeshObject*> m_meshobjects;
53
54         GEN_Map<CHashedPtr,struct Object*> m_map_gameobject_to_blender;
55         GEN_Map<CHashedPtr,KX_GameObject*> m_map_blender_to_gameobject;
56
57         GEN_Map<CHashedPtr,RAS_MeshObject*> m_map_mesh_to_gamemesh;
58 //      GEN_Map<CHashedPtr,DT_ShapeHandle> m_map_gamemesh_to_sumoshape;
59         
60         GEN_Map<CHashedPtr,SCA_IActuator*> m_map_blender_to_gameactuator;
61         GEN_Map<CHashedPtr,SCA_IController*> m_map_blender_to_gamecontroller;
62         
63         GEN_Map<CHashedPtr,BL_InterpolatorList*> m_map_blender_to_gameipolist;
64         
65         struct Main*                    m_maggie;
66         STR_String                              m_newfilename;
67         class KX_KetsjiEngine*  m_ketsjiEngine;
68         bool                                    m_alwaysUseExpandFraming;
69         
70 public:
71         KX_BlenderSceneConverter(
72                 struct Main* maggie,
73                 class KX_KetsjiEngine* engine
74         );
75
76         virtual ~KX_BlenderSceneConverter();
77
78         /* Scenename: name of the scene to be converted.
79          * destinationscene: pass an empty scene, everything goes into this
80          * dictobj: python dictionary (for pythoncontrollers)
81          */
82         virtual void    ConvertScene(
83                                                 const STR_String& scenename,
84                                                 class KX_Scene* destinationscene,
85                                                 PyObject* dictobj,
86                                                 class SCA_IInputDevice* keyinputdev,
87                                                 class RAS_IRenderTools* rendertools,
88                                                 class RAS_ICanvas* canvas
89                                         );
90
91         void SetNewFileName(const STR_String& filename);
92         bool TryAndLoadNewFile();
93
94         void SetAlwaysUseExpandFraming(bool to_what);
95         
96         void RegisterGameObject(KX_GameObject *gameobject, struct Object *for_blenderobject);
97         KX_GameObject *FindGameObject(struct Object *for_blenderobject);
98         struct Object *FindBlenderObject(KX_GameObject *for_gameobject);
99
100         void RegisterGameMesh(RAS_MeshObject *gamemesh, struct Mesh *for_blendermesh);
101         RAS_MeshObject *FindGameMesh(struct Mesh *for_blendermesh, unsigned int onlayer);
102
103 //      void RegisterSumoShape(DT_ShapeHandle shape, RAS_MeshObject *for_gamemesh);
104 //      DT_ShapeHandle FindSumoShape(RAS_MeshObject *for_gamemesh);
105
106         void RegisterPolyMaterial(RAS_IPolyMaterial *polymat);
107         
108         void RegisterInterpolatorList(BL_InterpolatorList *ipoList, struct Ipo *for_ipo);
109         BL_InterpolatorList *FindInterpolatorList(struct Ipo *for_ipo);
110
111         void RegisterGameActuator(SCA_IActuator *act, struct bActuator *for_actuator);
112         SCA_IActuator *FindGameActuator(struct bActuator *for_actuator);
113
114         void RegisterGameController(SCA_IController *cont, struct bController *for_controller);
115         SCA_IController *FindGameController(struct bController *for_controller);
116
117         void RegisterWorldInfo(KX_WorldInfo *worldinfo);
118 };
119
120 #endif //__KX_BLENDERSCENECONVERTER_H