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