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

SCA_ReplaceMeshActuator.cpp

Go to the documentation of this file.
00001 //
00002 // Replace the mesh for this actuator's parent
00003 //
00004 // Version: $Id: SCA_ReplaceMeshActuator_cpp-source.html,v 1.1 2001/02/01 12:25:16 coockie Exp $
00005 
00006 #include "SCA_IActuator.h"
00007 #include "SCA_ReplaceMeshActuator.h"
00008 #include "SCA_IScene.h"
00009 #include <iostream>
00010 
00011 /* ------------------------------------------------------------------------- */
00012 /* Python functions                                                          */
00013 /* ------------------------------------------------------------------------- */
00014 
00015 /* Integration hooks ------------------------------------------------------- */
00016 
00017 PyTypeObject SCA_ReplaceMeshActuator::Type = {
00018         PyObject_HEAD_INIT(&PyType_Type)
00019         0,
00020         "SCA_ReplaceMeshActuator",
00021         sizeof(SCA_ReplaceMeshActuator),
00022         0,
00023         PyDestructor,
00024         0,
00025         __getattr,
00026         __setattr,
00027         0, //&MyPyCompare,
00028         __repr,
00029         0, //&cvalue_as_number,
00030         0,
00031         0,
00032         0,
00033         0
00034 };
00035 
00036 PyParentObject SCA_ReplaceMeshActuator::Parents[] = {
00037         &SCA_IActuator::Type,
00038         &SCA_ILogicBrick::Type,
00039         &CValue::Type,
00040         NULL
00041 };
00042 PyMethodDef SCA_ReplaceMeshActuator::Methods[] = {
00043   {"setMesh", (PyCFunction) SCA_ReplaceMeshActuator::sPySetMesh, METH_VARARGS, SetMesh_doc},
00044 //    {"getMesh", (PyCFunction) SCA_ReplaceMeshActuator::sPyGetMesh, METH_VARARGS, GetMesh_doc},
00045   {NULL,NULL} //Sentinel
00046 };
00047 
00048 
00049 PyObject* SCA_ReplaceMeshActuator::_getattr(char* attr)

00050 {
00051   _getattr_up(SCA_IActuator);
00052 }
00053 
00054 /* 1. setMesh */
00055 char SCA_ReplaceMeshActuator::SetMesh_doc[] = 
00056 "setMesh(name)\n"
00057 "\t- name: string\n"
00058 "\tSet the mesh that will be substituted for the current one.\n";
00059 PyObject* SCA_ReplaceMeshActuator::PySetMesh(PyObject* self, 
00060                                                                                         PyObject* args, 
00061                                                                                         PyObject* kwds) {
00062         char* meshname;
00063         
00064         if (!PyArg_ParseTuple(args, "s", &meshname)) {
00065                 return NULL;    
00066         }
00067         void* mesh = SCA_ILogicBrick::m_sCurrentLogicManager->GetMeshByName(CCString(meshname));
00068         
00069         if (m_mesh) {
00070                 m_mesh= (class RAS_MeshObject*)mesh;
00071                 Py_Return;
00072         }
00073         
00074         return NULL;
00075 }
00076 
00077 /* ------------------------------------------------------------------------- */
00078 /* Native functions                                                          */
00079 /* ------------------------------------------------------------------------- */
00080 
00081 SCA_ReplaceMeshActuator::SCA_ReplaceMeshActuator(SCA_IObject *gameobj, 
00082                                                class RAS_MeshObject *mesh, 
00083                                                    SCA_IScene* scene,
00084                                                PyTypeObject* T)
00085         : SCA_IActuator(gameobj, T),
00086         m_scene(scene),
00087         m_mesh(mesh)

00088 {
00089     //m_replacementMesh = mesh;
00090 } /* End of constructor */
00091 
00092 SCA_ReplaceMeshActuator::~SCA_ReplaceMeshActuator()

00093 { 
00094         // there's nothing to be done here, really....
00095 } /* end of destructor */
00096 
00097 bool SCA_ReplaceMeshActuator::Update(double curtime,double deltatime)

00098 {
00099         bool result = false;    
00100         bool bNegativeEvent = IsNegativeEvent();
00101 
00102         if (bNegativeEvent)
00103                 return false; // do nothing on negative events
00104 
00105         if (m_mesh)
00106                 m_scene->ReplaceMesh(GetParent(),m_mesh);
00107         else
00108         {
00109                 cout << "\nSCA_ReplaceMeshActuator error: invalid mesh!";
00110         }
00111 
00112         
00113         return false;
00114 }
00115 
00116 /* eof */

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