libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo es el conjunto de objetos y funciones, que permiten ejecutar las operaciones básicas de la plataforma Moldeo, y que compone su núcleo.
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Amigas 'defines' Grupos Páginas
moTextureIndex.cpp
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moTextureIndex.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  #include "moTextureManager.h"
29 
30 *******************************************************************************/
31 
32 
33 #include "moTexture.h"
34 
35 
36 MOint moTextureIndex::Add(moText p_name, moTextureManager* p_tex_man) // Returns the index of the newly added texture.
37 {
38  MOint moid = p_tex_man->GetTextureMOId(p_name, true);
39  if (-1 < moid) return Add(p_tex_man->GetTexture(moid));
40  else return -1;
41 }
42 
44 {
45  MOint idx;
46  m_textures_array.Add(p_tex);
47  idx = m_textures_array.Count() - 1;
48  #ifdef _DEBUG
49  moText msg;
50  msg = moText("Texture added: ");
51  msg += m_textures_array[idx]->GetName();
52  MODebug2->Message(msg);
53  #endif
54  return idx;
55 }
56 
57 MOuint moTextureIndex::GetGLId(MOuint p_idx) // Without synchro...
58 {
59  if (ValidIndex(p_idx)) return m_textures_array[p_idx]->GetGLId();
60  return MO_UNDEFINED;
61 }
62 
63 MOuint moTextureIndex::GetGLId(MOuint p_idx, MOint p_cuad) // Without synchro, and arbitrary frame...
64 {
65  if (ValidIndex(p_idx))
66  if ((p_cuad >= 0) && ((m_textures_array[p_idx]->GetType() == MO_TYPE_TEXTURE_MULTIPLE) ||
67  (m_textures_array[p_idx]->GetType() == MO_TYPE_MOVIE) ||
68  (m_textures_array[p_idx]->GetType() == MO_TYPE_VIDEOBUFFER)))
69  {
70  moTextureAnimated* ptex_anim = (moTextureAnimated*)m_textures_array[p_idx];
71  return ptex_anim->GetGLId((MOuint)p_cuad);
72  }
73  else return m_textures_array[p_idx]->GetGLId();
74  else return 0;
75 }
76 
77 MOuint moTextureIndex::GetGLId(MOuint p_idx, MOfloat p_cycle) // Without synchro, and arbitrary frame...
78 {
79  if (ValidIndex(p_idx))
80  if ((p_cycle >= 0.0) && ((m_textures_array[p_idx]->GetType() == MO_TYPE_TEXTURE_MULTIPLE) ||
81  (m_textures_array[p_idx]->GetType() == MO_TYPE_MOVIE) ||
82  (m_textures_array[p_idx]->GetType() == MO_TYPE_VIDEOBUFFER)))
83  {
84  moTextureAnimated* ptex_anim = (moTextureAnimated*)m_textures_array[p_idx];
85  return ptex_anim ->GetGLId((MOfloat)p_cycle);
86  }
87  else return m_textures_array[p_idx]->GetGLId();
88  else return 0;
89 }
90 
91 MOuint moTextureIndex::GetGLId(MOuint p_idx, moTempo *p_tempo) // With synchro.
92 {
93  if (ValidIndex(p_idx))
94  if ((p_tempo != NULL) && ((m_textures_array[p_idx]->GetType() == MO_TYPE_TEXTURE_MULTIPLE) ||
95  (m_textures_array[p_idx]->GetType() == MO_TYPE_MOVIE) ||
96  (m_textures_array[p_idx]->GetType() == MO_TYPE_VIDEOBUFFER)))
97  {
98  moTextureAnimated* ptex_anim = (moTextureAnimated*)m_textures_array[p_idx];
99  float d = p_tempo->ang;
100  return ptex_anim->GetGLId(p_tempo);
101  }
102  else return m_textures_array[p_idx]->GetGLId();
103  else return 0;
104 }
105 
106 MOuint moTextureIndex::GetGLId(MOuint p_idx, moMoldeoObject *p_mob) // With synchro.
107 {
108  moTempo *p_tempo = NULL;
109 /*
110  if (ValidIndex(p_idx)) {
111  if (p_mob!=NULL) {
112  return m_textures_array[p_idx]->GetGLId( p_mob );
113  } else {
114  return m_textures_array[p_idx]->GetGLId();
115  }
116  } else return 0;
117  */
118  if (ValidIndex(p_idx))
119  if ((p_tempo != NULL) && ((m_textures_array[p_idx]->GetType() == MO_TYPE_TEXTURE_MULTIPLE) ||
120  (m_textures_array[p_idx]->GetType() == MO_TYPE_MOVIE) ||
121  (m_textures_array[p_idx]->GetType() == MO_TYPE_VIDEOBUFFER)))
122  {
123  moTextureAnimated* ptex_anim = (moTextureAnimated*)m_textures_array[p_idx];
124  return ptex_anim->GetGLId(p_tempo);
125  }
126  else return m_textures_array[p_idx]->GetGLId();
127  else return 0;
128 }
129 
131 {
132  if (ValidIndex(p_idx)) return (m_textures_array[p_idx]->GetType());
133  return -1;
134 }
135 
137 {
138  if (ValidIndex(p_idx)) return m_textures_array[p_idx];
139  return NULL;
140 }
141 
143 {
144  if (0<=p_idx && p_idx < m_textures_array.Count()) return true;
145  else
146  {
147  #ifdef _DEBUG
148  moText text;
149  text = moText("Error(moTextureIndex): the index: ");
150  text += IntToStr(p_idx);
151  text += moText(" does not exists.");
152  MODebug2->Error(text);
153  #endif
154  return false;
155  }
156 }
157 
158 MOuint moTextureIndex::LoadTextures(moConfig* p_cfg, MOuint p_param_idx, moTextureManager* p_tex_man)
159 {
160  MOint moid;
161  MOint idx = -1;
162  MOuint nImages = p_cfg->GetParam(p_param_idx).GetValuesCount();
163  moTexture* ptex;
164 
165  p_cfg->SetCurrentParamIndex(p_param_idx);
166  p_cfg->FirstValue();
167  for (MOuint i = 0; i < nImages; i++)
168  {
169  moid = p_tex_man->GetTextureMOId(&p_cfg->GetParam(), true);
170  if (-1 < moid)
171  {
172  idx++;
173  ptex = p_tex_man->GetTexture(moid);
174  m_textures_array.Add(ptex);
175  #ifdef _DEBUG
176  moText msg;
177  msg = moText("Texture loaded: ");
178  msg += ptex->GetName();
179  MODebug2->Message(msg);
180  #endif
181  } else {
182  m_textures_array.Add(NULL);
183  }
184  p_cfg->NextValue();
185  }
186  return m_textures_array.Count();
187 }
188 
MOint GetType(MOuint p_idx)
void Error(moText p_text)
Anuncia y registra un error.
Definition: moAbstract.cpp:79
Tempo, beat, ritmo.
Definition: moTempo.h:44
bool NextValue()
Selecciona el próximo valor del parámetro actual.
Definition: moConfig.cpp:1545
#define MO_UNDEFINED
Definition: moTypes.h:379
#define MOboolean
Definition: moTypes.h:385
textura múltiple
Definition: moTexture.h:55
#define MOfloat
Definition: moTypes.h:403
clase de para manejar textos
Definition: moText.h:75
moTexture * GetTexture(MOuint p_moid)
moTypes MOint moText moParamIndex moParamReference int iRow int int i int i
Definition: all_f.js:18
moTexture * GetTexture(MOuint p_idx)
moText GetName() const
Definition: moTexture.h:245
moText0 moText
Definition: moText.h:291
MOuint GetGLId(MOuint p_idx)
#define MOint
Definition: moTypes.h:388
Clase Base para Objetos Moldeo ( moEffect, moIODevice, moResource, moConsole )
MOint GetTextureMOId(moParam *param, MOboolean p_create_tex)
clase base para el manejo de una textura
Definition: moTexture.h:78
película
Definition: moTexture.h:56
TEXTURA BASE.
Definition: moTexture.h:54
static moDebug * MODebug2
Clase de impresión de errores para depuración.
Definition: moAbstract.h:225
function d
Definition: jquery.js:41
MOint Add(moText p_name, moTextureManager *p_tex_man)
moParam & GetParam(MOint p_paramindex=-1)
Devuelve el parámetro por índice.
Definition: moConfig.cpp:984
MOboolean ValidIndex(MOuint p_idx)
virtual MOint GetGLId(moTempo *tempo)
Definition: moTexture.cpp:1648
#define MOuint
Definition: moTypes.h:387
LIBMOLDEO_API moText0 IntToStr(int a)
Definition: moText.cpp:1070
bool SetCurrentParamIndex(int)
Selecciona el parámetro por el índice.
Definition: moConfig.cpp:1497
una textura asociada a una animación de cuadros
Definition: moTexture.h:549
MOuint GetValuesCount() const
Definition: moParam.cpp:1065
MOdouble ang
Definition: moTempo.h:81
void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
Definition: moAbstract.cpp:114
bool FirstValue()
Selecciona el primer valor del parámetro actual.
Definition: moConfig.cpp:1532
almacena la configuración de los parámetros de un objeto en un archivo XML
Definition: moConfig.h:193