Blender V2.61 - r43446
|
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 */ 00027 00032 #ifndef __KX_SOUNDACTUATOR 00033 #define __KX_SOUNDACTUATOR 00034 00035 #include "SCA_IActuator.h" 00036 00037 #ifdef WITH_AUDASPACE 00038 # include "AUD_C-API.h" 00039 # include "AUD_Reference.h" 00040 # include "AUD_IFactory.h" 00041 # include "AUD_IHandle.h" 00042 #endif 00043 00044 #include "BKE_sound.h" 00045 00046 typedef struct KX_3DSoundSettings 00047 { 00048 float min_gain; 00049 float max_gain; 00050 float reference_distance; 00051 float max_distance; 00052 float rolloff_factor; 00053 float cone_inner_angle; 00054 float cone_outer_angle; 00055 float cone_outer_gain; 00056 } KX_3DSoundSettings; 00057 00058 class KX_SoundActuator : public SCA_IActuator 00059 { 00060 Py_Header 00061 bool m_isplaying; 00062 AUD_Reference<AUD_IFactory> m_sound; 00063 float m_volume; 00064 float m_pitch; 00065 bool m_is3d; 00066 KX_3DSoundSettings m_3d; 00067 AUD_Reference<AUD_IHandle> m_handle; 00068 00069 void play(); 00070 00071 public: 00072 00073 enum KX_SOUNDACT_TYPE 00074 { 00075 KX_SOUNDACT_NODEF = 0, 00076 KX_SOUNDACT_PLAYSTOP, 00077 KX_SOUNDACT_PLAYEND, 00078 KX_SOUNDACT_LOOPSTOP, 00079 KX_SOUNDACT_LOOPEND, 00080 KX_SOUNDACT_LOOPBIDIRECTIONAL, 00081 KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP, 00082 KX_SOUNDACT_MAX 00083 }; 00084 00085 KX_SOUNDACT_TYPE m_type; 00086 00087 KX_SoundActuator(SCA_IObject* gameobj, 00088 AUD_Reference<AUD_IFactory> sound, 00089 float volume, 00090 float pitch, 00091 bool is3d, 00092 KX_3DSoundSettings settings, 00093 KX_SOUNDACT_TYPE type); 00094 00095 ~KX_SoundActuator(); 00096 00097 virtual bool Update(double curtime, bool frame); 00098 00099 CValue* GetReplica(); 00100 void ProcessReplica(); 00101 00102 #ifdef WITH_PYTHON 00103 00104 /* -------------------------------------------------------------------- */ 00105 /* Python interface --------------------------------------------------- */ 00106 /* -------------------------------------------------------------------- */ 00107 00108 KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, startSound); 00109 KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, pauseSound); 00110 KX_PYMETHOD_DOC_NOARGS(KX_SoundActuator, stopSound); 00111 00112 static int pyattr_set_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00113 static int pyattr_set_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00114 static int pyattr_set_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00115 static int pyattr_set_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00116 static int pyattr_set_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00117 static int pyattr_set_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef, PyObject *value); 00118 00119 static PyObject* pyattr_get_3d_property(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00120 static PyObject* pyattr_get_audposition(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00121 static PyObject* pyattr_get_gain(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00122 static PyObject* pyattr_get_pitch(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00123 static PyObject* pyattr_get_type(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00124 static PyObject* pyattr_get_sound(void *self, const struct KX_PYATTRIBUTE_DEF *attrdef); 00125 00126 #endif // WITH_PYTHON 00127 00128 }; 00129 00130 #endif //__KX_SOUNDACTUATOR 00131