Blender V2.61 - r43446

KX_VisibilityActuator.cpp

Go to the documentation of this file.
00001 /*
00002  * ***** BEGIN GPL LICENSE BLOCK *****
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software Foundation,
00016  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00017  *
00018  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00019  * All rights reserved.
00020  *
00021  * The Original Code is: all of this file.
00022  *
00023  * Contributor(s): none yet.
00024  *
00025  * ***** END GPL LICENSE BLOCK *****
00026  * Actuator to toggle visibility/invisibility of objects
00027  */
00028 
00034 #include "KX_VisibilityActuator.h"
00035 #include "KX_GameObject.h"
00036 
00037 KX_VisibilityActuator::KX_VisibilityActuator(
00038     SCA_IObject* gameobj,
00039     bool visible,
00040     bool occlusion,
00041     bool recursive
00042     ) 
00043     : SCA_IActuator(gameobj, KX_ACT_VISIBILITY),
00044       m_visible(visible),
00045       m_occlusion(occlusion),
00046       m_recursive(recursive)
00047 {
00048     // intentionally empty
00049 }
00050 
00051 KX_VisibilityActuator::~KX_VisibilityActuator(
00052     void
00053     )
00054 {
00055     // intentionally empty
00056 }
00057 
00058 CValue*
00059 KX_VisibilityActuator::GetReplica(
00060     void
00061     )
00062 {
00063     KX_VisibilityActuator* replica = new KX_VisibilityActuator(*this);
00064     replica->ProcessReplica();
00065     return replica;
00066 }
00067 
00068 bool
00069 KX_VisibilityActuator::Update()
00070 {
00071     bool bNegativeEvent = IsNegativeEvent();
00072     
00073     RemoveAllEvents();
00074     if (bNegativeEvent) return false;
00075 
00076     KX_GameObject *obj = (KX_GameObject*) GetParent();
00077     
00078     obj->SetVisible(m_visible, m_recursive);
00079     obj->SetOccluder(m_occlusion, m_recursive);
00080     obj->UpdateBuckets(m_recursive);
00081 
00082     return false;
00083 }
00084 
00085 #ifdef WITH_PYTHON
00086 
00087 /* ------------------------------------------------------------------------- */
00088 /* Python functions                                                          */
00089 /* ------------------------------------------------------------------------- */
00090 
00091 
00092 
00093 /* Integration hooks ------------------------------------------------------- */
00094 PyTypeObject KX_VisibilityActuator::Type = {
00095     PyVarObject_HEAD_INIT(NULL, 0)
00096     "KX_VisibilityActuator",
00097     sizeof(PyObjectPlus_Proxy),
00098     0,
00099     py_base_dealloc,
00100     0,
00101     0,
00102     0,
00103     0,
00104     py_base_repr,
00105     0,0,0,0,0,0,0,0,0,
00106     Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
00107     0,0,0,0,0,0,0,
00108     Methods,
00109     0,
00110     0,
00111     &SCA_IActuator::Type,
00112     0,0,0,0,0,0,
00113     py_base_new
00114 };
00115 
00116 PyMethodDef KX_VisibilityActuator::Methods[] = {
00117     {NULL,NULL} //Sentinel
00118 };
00119 
00120 PyAttributeDef KX_VisibilityActuator::Attributes[] = {
00121     KX_PYATTRIBUTE_BOOL_RW("visibility", KX_VisibilityActuator, m_visible),
00122     KX_PYATTRIBUTE_BOOL_RW("useOcclusion", KX_VisibilityActuator, m_occlusion),
00123     KX_PYATTRIBUTE_BOOL_RW("useRecursion", KX_VisibilityActuator, m_recursive),
00124     { NULL }    //Sentinel
00125 };
00126 
00127 #endif // WITH_PYTHON