libmoldeo (Moldeo 1.0 Core)
1.0
libmoldeo is the group of objects and functions that executes the basic operations of Moldeo 1.0 Platform.
moSequenceEffect.cpp
Ir a la documentación de este archivo.
1
/*******************************************************************************
2
3
moSequenceEffect.cpp
4
5
****************************************************************************
6
* *
7
* This source is free software; you can redistribute it and/or modify *
8
* it under the terms of the GNU General Public License as published by *
9
* the Free Software Foundation; either version 2 of the License, or *
10
* (at your option) any later version. *
11
* *
12
* This code is distributed in the hope that it will be useful, but *
13
* WITHOUT ANY WARRANTY; without even the implied warranty of *
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15
* General Public License for more details. *
16
* *
17
* A copy of the GNU General Public License is available on the World *
18
* Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19
* obtain it by writing to the Free Software Foundation, *
20
* Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21
* *
22
****************************************************************************
23
24
Copyright(C) 2006 Fabricio Costa
25
26
Authors:
27
Fabricio Costa
28
29
30
*******************************************************************************/
31
32
#include "
moSequenceEffect.h
"
33
/*
34
35
moSequenceEffect::moSequenceEffect() {
36
SetName("sequence");
37
SetType(MO_OBJECT_EFFECT);
38
}
39
40
moSequenceEffect::~moSequenceEffect() {
41
Finish();
42
}
43
44
MOboolean moSequenceEffect::Init()
45
{
46
if (!PreInit()) return false;
47
48
moDefineParamIndex( SEQUENCE_INLET, "inlet" );
49
moDefineParamIndex( SEQUENCE_OUTLET, "outlet" );
50
moDefineParamIndex( SEQUENCE_SCRIPT, "script" );
51
moDefineParamIndex( SEQUENCE_ALPHA, "alpha" );
52
moDefineParamIndex( SEQUENCE_COLOR, "color" );
53
moDefineParamIndex( SEQUENCE_SYNC, "syncro" );
54
moDefineParamIndex( SEQUENCE_PHASE, "phase" );
55
moDefineParamIndex( SEQUENCE_EFFECTS, "effects" );
56
moDefineParamIndex( SEQUENCE_STATES, "sequence_states" );
57
moDefineParamIndex( SEQUENCE_POSITION, "sequence_position" );
58
moDefineParamIndex( SEQUENCE_TOTAL_DURATION, "sequence_total_duration" );
59
moDefineParamIndex( SEQUENCE_PAUSED, "sequence_paused" );
60
moDefineParamIndex( SEQUENCE_MODE, "sequence_mode" );
61
moDefineParamIndex( SEQUENCE_LOOP, "sequence_loop" );
62
63
m_EffectManager.Init();
64
m_EffectManager.m_pEffectManager = &m_EffectManager;
65
m_EffectManager.m_pResourceManager = GetResourceManager();
66
67
m_Config.SetCurrentParam( "effects" );
68
69
int pre=-1,on=-1;
70
71
if (m_Config.FirstValue()) {
72
do {
73
moValue& mVal(m_Config.GetCurrentValue());
74
moMobDefinition MoldeoObjectDef( mVal.GetSubValue( MO_CFG_EFFECT).Text(), mVal.GetSubValue( MO_CFG_EFFECT_CONFIG).Text(),
75
MO_OBJECT_EFFECT, mVal.GetSubValue( MO_CFG_EFFECT_LABEL).Text() );
76
moEffect* newEffect = m_EffectManager.New( MoldeoObjectDef );
77
if (newEffect) {
78
newEffect->Init();
79
pre = mVal.GetSubValue(MO_CFG_EFFECT_PRE).Int();
80
on = mVal.GetSubValue(MO_CFG_EFFECT_ON).Int();
81
if (pre>=0) newEffect->GetConfig()->SetCurrentPreConf(pre);
82
if (on>0) newEffect->Activate();
83
else newEffect->Deactivate();
84
}
85
} while (m_Config.NextValue());
86
}
87
88
90
m_Config.SetCurrentParam( "sequence_states" );
91
m_n_sequence_states = m_Config.GetCurrentParam().GetValuesCount();
92
93
int i_sequence_states = 0;
94
95
if (m_Config.FirstValue()) {
96
do {
97
moValue& mVal(m_Config.GetCurrentValue());
98
moSequenceState SequenceState;
99
100
if (mVal.GetSubValueCount()>1) {
101
SequenceState.m_state_name = mVal.GetSubValue( 0 ).Text();
102
SequenceState.Set( mVal.GetSubValue( 1 ).Text());
103
}
104
105
m_SequenceStates[i_sequence_states] = SequenceState;
106
107
108
MODebug2->Message("sequence_states: " + mVal.GetSubValue( 0 ).Text() );
109
i_sequence_states+= 1;
110
} while (m_Config.NextValue());
111
}
112
m_Config[ moR(SEQUENCE_STATES)].SetIndexValue(0);
113
114
m_Config.SetCurrentPreConf( 0 );
115
116
return true;
117
}
118
119
int
120
moSequenceEffect::UpdateSequenceState( int i_state ) {
121
122
if (i_state>=m_n_sequence_states) return -1;
123
moSequenceState& SeqState( m_SequenceStates[i_state] );
124
128
129
if ( SeqState.m_Timer.Duration() ) {
130
131
}
132
133
return 0;
134
}
135
136
int
137
moSequenceEffect::NextSequenceState( int i_state ) {
138
139
int i_next_state = i_state + 1;
140
141
if (0<=i_state && i_state<m_n_sequence_states) {
142
MODebug2->Message("Next Sequence.");
143
} else {
144
if (m_Config.Int( moR(SEQUENCE_LOOP)) > 0) {
145
i_state = 0;
146
MODebug2->Message("Looping Sequence.");
147
} else {
148
i_state = m_n_sequence_states-1;
149
MODebug2->Message("End of Sequence reached.");
150
return -1;
151
}
152
}
153
154
return SetSequenceState( i_state );
155
}
156
157
int moSequenceEffect::SetSequenceState( int i_state ) {
158
159
int key = 0;
160
moEffect* pEffect=NULL;
161
162
if (i_state >= m_n_sequence_states) return -1;
163
164
moSequenceState& SeqState( m_SequenceStates[i_state] );
165
167
SeqState.m_Timer.Start();
168
170
for( key=0; key<m_EffectManager.AllEffects().Count(); key++) {
171
172
pEffect = m_EffectManager.AllEffects().Get(key);
173
174
if (pEffect) {
175
pEffect->Deactivate();
176
}
177
178
}
179
181
pEffect = m_EffectManager.GetEffectByLabel( SeqState.m_Key.m_label_name );
182
183
if (pEffect) {
184
if (SeqState.m_Key.m_active>0) pEffect->Activate();
185
if (SeqState.m_Key.m_preconfig_index>=0) pEffect->GetConfig()->SetCurrentPreConf( SeqState.m_Key.m_preconfig_index );
186
}
187
188
return 0;
189
}
190
191
void moSequenceEffect::UpdateParameters() {
192
194
if (m_i_sequence_states!=m_Config[ moR(SEQUENCE_STATES)].GetIndexValue()) {
195
m_i_sequence_states = m_Config[ moR(SEQUENCE_STATES)].GetIndexValue();
196
SetSequenceState(m_i_sequence_states);
197
} else {
198
//i_sequence_states = m_Config[ moR(SEQUENCE_STATES)].GetIndexValue()
199
UpdateSequenceState(m_i_sequence_states);
200
}
201
202
}
203
204
void moSequenceEffect::Draw( moTempo* tempogral,moEffectState* parentstate)
205
{
206
moEffect* pEffect = NULL;
207
moRenderManager* RenderMan = GetResourceManager()->GetRenderMan();
208
209
UpdateParameters();
210
211
BeginDraw( tempogral, parentstate);
212
213
glMatrixMode( GL_MODELVIEW );
214
glPushMatrix(); // Store The Modelview Matrix
215
glLoadIdentity();
216
217
218
for( int i=0; i<m_EffectManager.Effects().Count(); i++ ) {
219
220
pEffect = m_EffectManager.Effects().GetRef(i);
221
if(pEffect) {
222
if(pEffect->Activated()) {
223
RenderMan->BeginDrawEffect();
224
pEffect->Draw(&m_EffectState.tempo);
225
RenderMan->EndDrawEffect();
226
}
227
}
228
}
229
230
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
231
glPopMatrix(); // Restore The Old Projection Matrix
232
233
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
234
glPopMatrix(); // Restore The Old Projection Matrix
235
236
EndDraw();
237
}
238
239
MOboolean moSequenceEffect::Finish()
240
{
241
return PreFinish();
242
}
243
244
void moSequenceEffect::Interaction(moIODeviceManager *consolaes) {
245
consolaes = NULL;///unused
246
}
247
248
249
void
250
moSequenceEffect::LoadCodes(moIODeviceManager *consolaesarray) {
251
252
//cargamos el especifico a este luego el de los efectos dentro del array
253
moEffect::LoadCodes(consolaesarray);
254
255
256
}
257
*/
moSequenceEffect.h
libmoldeo
moSequenceEffect.cpp
Generado el Martes, 10 de Septiembre de 2019 21:27:08 para libmoldeo (Moldeo 1.0 Core) por
1.8.13