Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

KX_SceneActuator.cpp

Go to the documentation of this file.
00001 
00006 
00007 #include "SCA_IActuator.h"
00008 #include "KX_SceneActuator.h"
00009 #include <iostream>
00010 #include "KX_Scene.h"
00011 #include "KX_Camera.h"
00012         
00013 /* ------------------------------------------------------------------------- */
00014 /* Native functions                                                          */
00015 /* ------------------------------------------------------------------------- */
00016 
00017 KX_SceneActuator::KX_SceneActuator(SCA_IObject *gameobj, 
00018                                                                    int mode,
00019                                                                    KX_Scene *scene,
00020                                                                    KX_Camera* camera,
00021                                                                    PyTypeObject* T)
00022         : SCA_IActuator(gameobj, T)

00023 {
00024         m_mode = mode;
00025         m_scene  = scene;
00026         m_camera = camera;
00027 } /* End of constructor */
00028 
00029 KX_SceneActuator::~KX_SceneActuator()

00030 { 
00031         // there's nothing to be done here, really....
00032 } /* end of destructor */
00033 
00034 bool KX_SceneActuator::Update(double curtime,double deltatime)

00035 {
00036         bool result = false;    
00037         bool bNegativeEvent = IsNegativeEvent();
00038 
00039         if (bNegativeEvent)
00040                 return false; // do nothing on negative events
00041 
00042 
00043         switch (m_mode) {
00044         case KX_SCENE_RESTART:
00045 //              cout << "\n Scene: restart";
00046                 break;
00047         case KX_SCENE_SET_SCENE:
00048                 
00049 //              cout << "\n Scene: set scene";
00050                 break;
00051         case KX_SCENE_SET_CAMERA:
00052                 if (m_camera)
00053                 {
00054                         m_scene->SetActiveCamera(m_camera);
00055                 }
00056 //              cout << "\n Scene: set camera";
00057                 break;
00058         default:
00059                 ; /* do nothing? this is an internal error !!! */
00060         }
00061                 
00062         return false;
00063 }
00064 
00065 void *KX_SceneActuator::findCamera(char * camName) {
00066         return NULL;
00067 }
00068 
00069 void *KX_SceneActuator::findScene(char * sceneName) {
00070         return NULL;
00071 }
00072 
00073 
00074 /* ------------------------------------------------------------------------- */
00075 /* Python functions                                                          */
00076 /* ------------------------------------------------------------------------- */
00077 
00078 /* Integration hooks ------------------------------------------------------- */
00079 PyTypeObject KX_SceneActuator::Type = {
00080         PyObject_HEAD_INIT(&PyType_Type)
00081         0,
00082         "KX_SceneActuator",
00083         sizeof(KX_SceneActuator),
00084         0,
00085         PyDestructor,
00086         0,
00087         __getattr,
00088         __setattr,
00089         0, //&MyPyCompare,
00090         __repr,
00091         0, //&cvalue_as_number,
00092         0,
00093         0,
00094         0,
00095         0
00096 };
00097 
00098 PyParentObject KX_SceneActuator::Parents[] = {
00099         &KX_SceneActuator::Type,
00100         &SCA_IActuator::Type,
00101         &SCA_ILogicBrick::Type,
00102         &CValue::Type,
00103         NULL
00104 };
00105 
00106 PyMethodDef KX_SceneActuator::Methods[] = {
00107         {"setUseRestart", (PyCFunction) KX_SceneActuator::sPySetUseRestart, METH_VARARGS, SetUseRestart_doc},
00108         {"setScene",      (PyCFunction) KX_SceneActuator::sPySetScene, METH_VARARGS, SetScene_doc},
00109         {"setCamera",     (PyCFunction) KX_SceneActuator::sPySetCamera, METH_VARARGS, SetCamera_doc},
00110         {"getUseRestart", (PyCFunction) KX_SceneActuator::sPyGetUseRestart, METH_VARARGS, GetUseRestart_doc},
00111         {"getScene",      (PyCFunction) KX_SceneActuator::sPyGetScene, METH_VARARGS, GetScene_doc},
00112         {"getCamera",     (PyCFunction) KX_SceneActuator::sPyGetCamera, METH_VARARGS, GetCamera_doc},
00113         {NULL,NULL} //Sentinel
00114 };
00115 
00116 PyObject* KX_SceneActuator::_getattr(char* attr) {
00117         _getattr_up(SCA_IActuator);
00118 }
00119 
00120 /* 2. setUseRestart--------------------------------------------------------- */
00121 char KX_SceneActuator::SetUseRestart_doc[] = 
00122 "setUseRestart(flag)\n"
00123 "\t- flag: 0 or 1.\n"
00124 "\tSet flag to 1 to restart the scene.\n" ;
00125 PyObject* KX_SceneActuator::PySetUseRestart(PyObject* self, 
00126                                                                                         PyObject* args, 
00127                                                                                         PyObject* kwds) {
00128         int boolArg;
00129         
00130         if (!PyArg_ParseTuple(args, "i", &boolArg)) {
00131                 return NULL;
00132         }
00133 
00134         if (boolArg == KX_TRUE) {
00135                 m_restart = true;
00136         } else if (boolArg == KX_FALSE){
00137                 m_restart = false;
00138         } else {
00139                 ; /* internal error */
00140         }
00141         
00142         Py_Return;
00143 }
00144 
00145 /* 3. getUseRestart:                                                         */
00146 char KX_SceneActuator::GetUseRestart_doc[] = 
00147 "getUseRestart()\n"
00148 "\tReturn whether the scene will be restarted.\n" ;
00149 PyObject* KX_SceneActuator::PyGetUseRestart(PyObject* self, 
00150                                                                                  PyObject* args, 
00151                                                                                  PyObject* kwds)

00152 {
00153         return PyInt_FromLong(!(m_restart == 0));
00154 }
00155 
00156 /* 4. set scene------------------------------------------------------------- */
00157 char KX_SceneActuator::SetScene_doc[] = 
00158 "setScene(scene)\n"
00159 "\t- scene: string\n"
00160 "\tSet the scene to switch to.\n" ;
00161 PyObject* KX_SceneActuator::PySetScene(PyObject* self, 
00162                                                                            PyObject* args, 
00163                                                                            PyObject* kwds) {
00164         /* one argument: a scene, ignore the rest */
00165         char *sceneName;
00166         //KX_Scene*     sceneOb;
00167 
00168         if(!PyArg_ParseTuple(args, "s", &sceneName)) {
00169                 return NULL;
00170         }
00171         /* now convert and set... */
00172         // NOT YET!
00173 
00174         //sceneOb = findScene(sceneName);
00175 
00176         //if (sceneOb) {
00177         //      m_mode = KX_SCENE_SET_SCENE;
00178         //      m_scene = sceneOb;
00179         //}
00180 
00181         
00182         Py_Return;
00183 }
00184 
00185 /* 5. getScene:                                                              */
00186 char KX_SceneActuator::GetScene_doc[] = 
00187 "getScene(scene)\n"
00188 "\t- scene: string\n"
00189 "\tReturn the scene to switch to.\n" ;
00190 PyObject* KX_SceneActuator::PyGetScene(PyObject* self, 
00191                                                                            PyObject* args, 
00192                                                                            PyObject* kwds)

00193 {
00194         Py_Return;
00195 }
00196 
00197 /* 6. set camera------------------------------------------------------------ */
00198 char KX_SceneActuator::SetCamera_doc[] = 
00199 "setCamera(camera)\n"
00200 "\t- camera: string\n"
00201 "\tSet the camera to switch to.\n" ;
00202 PyObject* KX_SceneActuator::PySetCamera(PyObject* self, 
00203                                                                                 PyObject* args, 
00204                                                                                 PyObject* kwds) {
00205         /* one argument: a scene, ignore the rest */
00206         char *camName;
00207 //      KX_Camera *camOb;
00208 
00209         if(!PyArg_ParseTuple(args, "s", &camName)) {
00210                 return NULL;
00211         }
00212         /* now convert and set... */
00213         //camOb = findCamera(camName);
00214         
00215         // not yet
00216         //if (camOb) {
00217         //      m_mode = KX_SCENE_SET_SCENE;
00218         //      m_camera = camOb;
00219         //}
00220         Py_Return;
00221 }
00222 
00223 /* 7. getCamera:                                                             */
00224 char KX_SceneActuator::GetCamera_doc[] = 
00225 "getCamera(camera)\n"
00226 "\t- camera: string\n"
00227 "\tReturn the camera to switch to.\n" ;
00228 PyObject* KX_SceneActuator::PyGetCamera(PyObject* self, 
00229                                                                                 PyObject* args, 
00230                                                                                 PyObject* kwds)

00231 {
00232         Py_Return;
00233 }
00234 
00235 
00236 /* eof */

Generated at Thu Feb 1 13:03:07 2001 for Ketsji Game Engine by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000