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
mo3dModelManager.cpp
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  mo3dModelManager.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 #include <string>
32 #include <mo3dModelManager.h>
33 #include <mo3ds.h>
34 #include <moDataManager.h>
35 #include <moTextureManager.h>
36 
37 
38 #include "moArray.h"
39 moDefineDynamicArray( moCoords )
40 moDefineDynamicArray( moSceneNodeArray )
41 moDefineDynamicArray( moSceneNodePointerArray )
42 
43 MOulong moSceneNode::UID = 0;
44 
45 MOulong moSceneNode::CreateUID() {
46  moSceneNode::UID+= 1;
47  return moSceneNode::UID;
48 }
49 
53 }
54 
57  m_Name = name;
58 }
59 
61  (*this) = p_src;
62 }
63 
68  m_Parent = p_src.m_Parent;
70  m_Childrens = p_src.m_Childrens;
71  return (*this);
72 }
73 
75 
76 }
77 
79 
80  return true;
81 
82 }
83 
85  return true;
86 }
87 
90  moSceneNode* nFind = NULL;
91  for( MOuint i=0; i<m_Childrens.Count(); i++ ) {
92  nFind = m_Childrens[i];
93 
94  if (nFind && nFind->GetName()==p_name) {
95  return nFind;
96  }
97 
98  if (nFind) nFind = nFind->GetObjectByName( p_name );
99  if (nFind) return nFind;
100  }
101  return nFind;
102 }
103 
106  moSceneNode* nFind = NULL;
107  for( MOuint i=0; i<m_Childrens.Count(); i++ ) {
108  nFind = m_Childrens[i];
109 
110  if (nFind && nFind->GetId()==p_id) {
111  return nFind;
112  }
113 
114  if (nFind) nFind = nFind->GetObjectById( p_id );
115  if (nFind) return nFind;
116  }
117  return nFind;
118 }
119 
121 moSceneNode::GetChild( int p_index_child ) {
122  return m_Childrens.Get(p_index_child);
123 }
124 
126  m_Childrens.Add( p_child_node );
127  return 0;
128 }
129 
130 int moSceneNode::RemoveChild( int p_node_index ) {
131  m_Childrens.Remove( p_node_index );
132  return 1;
133 }
134 
136 
137  if (p_child_node==NULL) return -1;
138  //search for node
139  for( int i=0; i<(int)m_Childrens.Count(); i++ ) {
140  if (p_child_node==m_Childrens[i]) {
141  m_Childrens.Remove(i);
142  return 1;
143  }
144  }
145  return 0;
146 }
147 
148 
149 void moSceneNode::Draw( moEffectState *state, GLuint g_ViewMode ) {
150 
151  // draw scene node
152  moText json;
153 
154  if (state)
155  json = state->ToJSON();
156 
157  MODebug2->Message( "moSceneNode::Draw > implement this! g_ViewMode: (" + IntToStr(g_ViewMode) + ") "
158  + json );
159 }
160 
162 
163 }
164 
166 
167 }
168 
169 
170 
171 
172 
173 
175  m_pModel = NULL;
176 }
177 
178 
180 
181 }
182 
183 MOboolean
185  m_pModel = NULL;
186  return true;
187 }
188 
190  return true;
191 }
192 
193 
194 void mo3DSModelSceneNode::Draw(moEffectState *state, GLuint g_ViewMode) {
195 
196  int i;
197  float x,y;
198  int TID;
199  mo3DSMaterialInfo MAT;
200 
201 
202  if (m_pModel)
203  for(i = 0; i < m_pModel->numOfObjects; i++)
204  {
205  // Make sure we have valid objects just in case.(size() is in the vector class)
206  if(m_pModel->pObject.size() <= 0) break;
207 
208  // Get the current object that we are displaying
209  mo3DSObject *pObject = &m_pModel->pObject[i];
210 
211  // Check to see if this object has a texture map, if so bind the texture to it.
212  //if pObject->materialID
213  //if(pObject->pMaterials[pObject->materialID].texureId
214 
215  if(pObject->bHasTexture) {
216 
217  // Turn on texture mapping and turn off color
218  glEnable(GL_TEXTURE_2D);
219 
220  // Reset the color to normal again
221  glColor4f(state->tintr, state->tintg, state->tintb,state->alpha);
222 
223  // Bind the texture map to the object by it's materialID
224  if(m_pModel->pMaterials.size() && pObject->materialID >= 0) {
225  TID = -1;
226  MAT = m_pModel->pMaterials[pObject->materialID];
227  if ( MAT.texMaps.size()) {
228  TID = MAT.texMaps[0].textureId;
229  }
230  if ( TID!=65535 && TID>0) {
231  glBindTexture(GL_TEXTURE_2D, TID );
232  } else {
233  glBindTexture(GL_TEXTURE_2D, 1 );
234  }
235  }
236  } else {
237 
238  // Turn off texture mapping and turn on color
239  glDisable(GL_TEXTURE_2D);
240 
241  // Reset the color to normal again
242  glColor4f( state->tintr, state->tintg, state->tintb, state->alpha );
243  }
244 
245  // This determines if we are in wireframe or normal mode
246 #ifndef OPENGLESV2
247  glBegin(g_ViewMode); // Begin drawing with our selected mode(triangles or lines)
248 
249  // Go through all of the faces(polygons) of the object and draw them
250  for(int j = 0; j < pObject->numOfFaces; j++)
251  {
252  // Go through each corner of the triangle and draw it.
253  for(int whichVertex = 0; whichVertex < 3; whichVertex++)
254  {
255  // Get the index for each point of the face
256  int index = pObject->pFaces[j].vertIndex[whichVertex];
257 
258  // Give OpenGL the normal for this vertex.
259  glNormal3f(pObject->pNormals[ index ].x, pObject->pNormals[ index ].y, pObject->pNormals[ index ].z);
260 
261  // If the object has a texture associated with it, give it a texture coordinate.
262  if(pObject->bHasTexture) {
263 
264  // Make sure there was a UVW map applied to the object or else it won't have tex coords.
265  if(pObject->pTexVerts) {
266  //BYTE *pColor = m_pModel->pMaterials[pObject->materialID].color;
267 
268  // Assign the current color to this model
269  //glColor3ub(pColor[0]*state.tintr, pColor[1]*state.tintg, pColor[2]*state.tintb);
270  //glColor4ub( pColor[0]*state->tintr, pColor[1]*state->tintg, pColor[2]*state->tintb,255*state->alpha );
271 
272  MOubyte *pColor = m_pModel->pMaterials[pObject->materialID].colorDiffuse;
273 
274  // Assign the current color to this model
275  if (pColor!=NULL) {
276  float rf = (float)pColor[0] * state->tintr;
277  float rg = (float)pColor[1] * state->tintg;
278  float rb = (float)pColor[2] * state->tintb;
279  float af = 255.0 * state->alpha;
280  glColor4f( rf, rg, rb, af);
281  } else glColor4f(state->tintr, state->tintg, state->tintb,state->alpha);
282 
283  if ( MAT.texMaps.size()) {
284  x = pObject->pTexVerts[ index ].x * MAT.texMaps[0].vTile + MAT.texMaps[0].vOffset;
285  y = pObject->pTexVerts[ index ].y * MAT.texMaps[0].uTile + MAT.texMaps[0].uOffset;
286  } else {
287  x = pObject->pTexVerts[ index ].x;
288  y = pObject->pTexVerts[ index ].y;
289  }
290 
291  glTexCoord2f( x , y );
292  }
293  } else {
294 
295  // Make sure there is a valid material/color assigned to this object.
296  // You should always at least assign a material color to an object,
297  // but just in case we want to check the size of the material list.
298  // if the size is at least one, and the material ID != -1,
299  // then we have a valid material.
300  if(m_pModel->pMaterials.size() && pObject->materialID >= 0)
301  {
302  // Get and set the color that the object is, since it must not have a texture
303  MOubyte *pColor = m_pModel->pMaterials[pObject->materialID].colorDiffuse;
304 
305  // Assign the current color to this model
306  if ( pColor!=NULL) {
307  float rf = (float)pColor[0] * state->tintr;
308  float rg = (float)pColor[1] * state->tintg;
309  float rb = (float)pColor[2] * state->tintb;
310  float af = 255.0 * state->alpha;
311  glColor4f( rf, rg, rb, af);
312  } else glColor4f(state->tintr, state->tintg, state->tintb,state->alpha);
313  }
314  }
315 
316  // Pass in the current vertex of the object(Corner of current face)
317  glVertex3f(pObject->pVerts[ index ].x, pObject->pVerts[ index ].y, pObject->pVerts[ index ].z);
318  }
319  }
320 
321  glEnd();
322 #endif // End the drawing
323  }
324 
325 
326 }
327 
329 
330 }
331 
333 
334 }
335 
336 //===========================================
337 //
338 // mo3dModelManager
339 //
340 //===========================================
341 
342 
343 
347  SetName("3dmodelmanager");
348  SetLabelName("3d Model Manager");
349  mTM = NULL;
350  m_pMoldeoLogo = NULL;
351 /*
352  nMaxModels = MO_MAX_MODELOS;
353  Models = new mo3dModel* [nMaxModels];
354  for(MOuint i=0;i<nMaxModels;i++) Models[i] = NULL;
355  nModels = 0;
356  Textures = NULL;
357 */
358 }
359 
361  Finish();
362 }
363 
364 MOboolean
366  m_pMoldeoLogo = NULL;
367  if ( m_pResourceManager ) {
369  }
370 
371  m_pMoldeoLogo = Load3dModel("moldeologo.3ds" );
372  if (m_pMoldeoLogo) {
373  MODebug2->Message("mo3dModelManager::Init > loaded Moldeo 3ds Model!!! ");
374  }
375  /*
376  if (!m_pMoldeoLogo) {
377  mo3dModel* pmodel = Load3dModel("moldeologo.3ds", m_pResourceManager->GetDataMan()->GetAppDataPath() );
378  if (pmodel) {
379  m_pMoldeoLogo = new mo3DModelSceneNode();
380  m_pMoldeoLogo->Init(pmodel);
381  }
382  }
383  */
384  return true;
385 }
386 
387 
388 //Devuelve el puntero generado
389 //en caso de no encontrar el archivo, devuelve MOTEXTURAS_ERROR
390 
392 mo3dModelManager::Load3dModel( const moText& p_file_name ) {
393 
394 // MOint i,j;
395  CLoad3DS g_Load3ds; // Clase importacion de escenas 3DS.
396 
397  moText strTexture;
398  moText filename;
399 // MOuint texid=MO_UNDEFINED;
400 
401  moFile File3D = m_pResourceManager->GetDataMan()->GetDataFile( p_file_name );
402 
403  if (!File3D.Exists()) {
405  File3D = m_pResourceManager->GetDataMan()->GetAppDataFile( p_file_name );
406  if (!File3D.Exists()) {
407  MODebug2->Error( "mo3dModelManager::Load3dModel > file not found! " + File3D.GetFullName() );
408  }
409  }
410 
411 /*
412  if(Models[nModels]!=NULL) {
413  Models[nModels]->numOfMaterials = 0;
414  Models[nModels]->numOfObjects = 0;
415 
416  if(g_Load3ds.Import3DS( Models[nModels], file3d) == true) {
417 
418  for(i = 0; i < Models[nModels]->numOfMaterials; i++)
419  {
420  //check all maps of the material
421  for(j=0;j<(MOint)Models[nModels]->pMaterials[i].texMaps.size();j++) {
422  // Check to see if there is a file name to load in this material
423  if(strlen(Models[nModels]->pMaterials[i].texMaps[j].strFile) > 0)
424  {
425  // Use the name of the texture file to load the bitmap, with a texture ID(i).
426  // We pass in our global texture array, the name of the texture, and an ID to reference it.
427  //CreateTexture(g_Texture, g_3DModel.pMaterials[i].strFile, i);
428  strTexture = Models[nModels]->pMaterials[i].texMaps[j].strFile;
429  strTexture = moText("objetos/materials/")+(moText)strTexture;
430  texid = Textures->GetTextureMOId(strTexture, true);
431  }
432 
433  // Set the texture ID for this material
434  //if(texid!=MOTEXTURAS_ERROR) {
435  Models[nModels]->pMaterials[i].texMaps[j].textureId = texid;
436  //}
437  }
438  }
439  Models[nModels]->name = Tname;
440  } else {
441  delete Models[nModels];
442  Models[nModels] = NULL;
443  return NULL;
444  }
445  } else return(NULL);
446 
447  nModels++;
448  return Models[nModels-1];
449  */
450  return NULL;
451 }
452 
453 
454 MOboolean
456  /*
457  MOuint i;
458  if(nModels>0) {
459  for(i=0;i<nModels;i++) {
460  if(Models[i]!=NULL) {
461  for(int j = 0; j < Models[i]->numOfObjects; j++)
462  {
463  // Free the faces, normals, vertices, and texture coordinates.
464  delete [] Models[i]->pObject[j].pFaces;
465  delete [] Models[i]->pObject[j].pNormals;
466  delete [] Models[i]->pObject[j].pVerts;
467  delete [] Models[i]->pObject[j].pTexVerts;
468  }
469 
470  delete Models[i];
471  Models[i] = NULL;
472  }
473  }
474  }
475  if(Models!=NULL) delete [] Models;
476  Models = NULL;
477  nModels = 0;
478 
479  if (m_pMoldeoLogo) {
480  delete m_pMoldeoLogo;
481  m_pMoldeoLogo = NULL;
482  }
483 */
484  return true;
485 }
486 
488 mo3dModelManager::Get3dModel( const moText& p_object_name, bool force_load ) {
489 
490  //buscamos a ver si no lo cargamos ya
491  //si no se encontro el modelo se lo carga
492  moSceneNode* pFind = m_MotherNode.GetObjectByName( p_object_name );
493  if (!pFind && force_load) {
494  pFind = Load3dModel( p_object_name );
495  }
496  return( pFind );
497 }
498 
500 
501  //animate
502 
503  cout << "mo3dModelManager::MoldeoLogo > ticks: " << ticks << endl;
504 
505 /*
506  moEffectState pstate;
507  pstate.tintr = 1.0;
508  pstate.tintg = 1.0;
509  pstate.tintb = 1.0;
510  pstate.tint = 1.0;
511  pstate.alpha = 1.0;
512 
513  glClearColor( 0.0f, 0.0f, 0.3f, 0.0f );
514  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
515 #ifndef OPENGLESV2
516  glDisable(GL_LIGHTING);
517  glDisable(GL_TEXTURE_2D);
518  glDisable(GL_COLOR_MATERIAL);
519  glDisable(GL_BLEND);
520  glDisable(GL_CULL_FACE);
521  glPolygonMode(GL_FRONT_AND_BACK,GL_FILL);
522 
523  // Transformations
524  //GLfloat m[4][4];
525  glMatrixMode( GL_MODELVIEW );
526  glLoadIdentity();
527  glRotatef(33, 0, 0 , 1 );
528  glTranslatef( 0.0f, 0.0f, -4.0f );
529  glRotatef( (ticks/100.0)*8, 0.0f, 1.0f, 0.0f );
530  glScalef(3,3,3);
531  //glTranslatef( 0.6f, 0.0f, 0.0f );
532 
533  if (m_pMoldeoLogo)
534  m_pMoldeoLogo->Draw( &pstate, GL_TRIANGLES);
535 #endif
536 */
537 }
538 
539 
540 //===========================================
541 //
542 // mo3dModelManagerRef
543 //
544 //========================================
545 
546 
547 /*
548 void
549 mo3dModelManagerRef::LoadModels(moConfig *cfg,MOuint param,mo3dModelManager*M) {
550 
551  MOuint i;
552  moText namemodelo;
553 
554  cfg->SetCurrentParamIndex(param);
555  cfg->FirstValue();
556  for(i=0;i<nModels;i++) {
557  namemodelo = cfg->GetParam().GetValue().GetSubValue(0).Text();
558  Models[i] = M->Get3dModel(namemodelo);
559  if(Models[i] != MO_3DMODEL_ERROR) {
560  MODebug2->Message(moText("Modelo cargado: ") + (moText)Models[i]->name);
561  } else {
562  MODebug2->Error(moText("mo3dModelManagerRef::LoadModels > Modelo no cargado: "));
563  }
564  cfg->NextValue();
565  }
566 }
567 
568 int mo3dModelManagerRef::Add(moText namemodelo,mo3dModelManager *M) {
569 
570  MOint i;
571 
572  mo3dModel* newModel = NULL;
573 
574  //y alli cargamos la textura
575  newModel = M->Get3dModel(namemodelo);
576 
577  if(newModel != MO_3DMODEL_ERROR) {
578 
579  mo3dModel **ModelsAux = NULL;
580 
581  ModelsAux = new mo3dModel* [nModels+1];
582 
583  if(Models!=NULL) {
584  //copio el contenido del buffer
585  for(i=0;i<(int)nModels;i++) {
586  ModelsAux[i] = Models[i];
587  }
588  //borro el buffer viejo
589  delete[] Models;
590  Models = NULL;
591  }
592 
593  //aumentamos el array de uno
594  nModels++;
595  //recreamos el buffer con un elemento mas
596  Models = new mo3dModel* [nModels];
597  //lo completamos otra vez con los datos guardados en memoria
598  if(Models!=NULL) {
599  for(i=0;i<(int)nModels-1;i++) {
600  Models[i] = ModelsAux[i];
601  }
602  }
603  //nos paramos en el last
604  i = nModels - 1 ;
605 
606  Models[i] = newModel;
607  MODebug2->Message(moText("Modelo cargado: ") + (moText)Models[i]->name);
608 
609  delete [] ModelsAux;
610  return i;
611  } else {
612  MODebug2->Error(moText("mo3dModelManagerRef::Add > Modelo no cargado: "));
613  }
614 
615  return MO_UNDEFINED;
616 }
617 
618 mo3dModelManagerRef::mo3dModelManagerRef() {
619  nModels = 0;
620  Models = NULL;
621 }
622 
623 mo3dModelManagerRef::~mo3dModelManagerRef() {
624  Finish();
625 }
626 
627 
628 MOboolean
629 mo3dModelManagerRef::Init(moConfig * cfg, MOuint param, mo3dModelManager *M) {
630  moText text;
631 
632  nModels = cfg->GetValuesCount(param);
633  text = moText("nModels: ");
634  text += IntToStr(nModels);
635  MODebug2->Push(text);
636  Models = new mo3dModel* [nModels];
637  for(MOuint i=0;i<nModels;i++) Models[i] = NULL;
638 
639  MODebug2->Push(moText("Espacio asignado: cargando modelos... 8o|"));
640  LoadModels(cfg,param,M);
641  MODebug2->Push(moText("Models cargados 8oD"));
642  return true;
643 }
644 
645 MOboolean
646 mo3dModelManagerRef::Finish() {
647  if(Models!=NULL) delete[] Models;
648  Models = NULL;
649  nModels = 0;
650  return true;
651 }
652 
653 mo3dModel*
654 mo3dModelManagerRef::Get(int i) {
655 
656  if((i>=0) &&(i<(MOint)nModels)) {
657  return(Models[i]);
658  } else {
659  moText text;
660  text = moText("Error(ajModelsRef): el indice: ");
661  text += IntToStr(i);
662  text += moText(" no existe.");
663  MODebug2->Error(text);
664  return(0);
665  }
666 }
667 
668 
669 
670 void mo3dModelManagerRef::Draw(int imodel, moEffectState *state, GLuint g_ViewMode) {
671 
672  // Since we know how many objects our model has, go through each of them.
673  int i;
674  float x,y;
675  int TID;
676  moMaterialInfo MAT;
677 
678  if ( imodel < (int)this->nModels )
679  if (Models[imodel]!=NULL)
680  for(i = 0; i < Models[imodel]->numOfObjects; i++)
681  {
682  // Make sure we have valid objects just in case.(size() is in the vector class)
683  if(Models[imodel]->pObject.size() <= 0) break;
684 
685  // Get the current object that we are displaying
686  mo3dObject *pObject = &Models[imodel]->pObject[i];
687 
688  // Check to see if this object has a texture map, if so bind the texture to it.
689  //if pObject->materialID
690  //if(pObject->pMaterials[pObject->materialID].texureId
691 
692  if(pObject->bHasTexture) {
693 
694  // Turn on texture mapping and turn off color
695  glEnable(GL_TEXTURE_2D);
696 
697  // Reset the color to normal again
698  glColor4f(state->tintr, state->tintg, state->tintb,state->alpha);
699 
700  // Bind the texture map to the object by it's materialID
701  if(Models[imodel]->pMaterials.size() && pObject->materialID >= 0) {
702  TID = -1;
703  MAT = Models[imodel]->pMaterials[pObject->materialID];
704  if ( MAT.texMaps.size()) {
705  TID = MAT.texMaps[0].textureId;
706  }
707  if ( TID!=65535 && TID>0) {
708  glBindTexture(GL_TEXTURE_2D, TID );
709  } else {
710  glBindTexture(GL_TEXTURE_2D, 1 );
711  }
712  }
713  } else {
714 
715  // Turn off texture mapping and turn on color
716  glDisable(GL_TEXTURE_2D);
717 
718  // Reset the color to normal again
719  glColor4f( state->tintr, state->tintg, state->tintb, state->alpha );
720  }
721 
722 #ifndef OPENGLESV2
723  // This determines if we are in wireframe or normal mode
724  glBegin(g_ViewMode); // Begin drawing with our selected mode(triangles or lines)
725 
726  // Go through all of the faces(polygons) of the object and draw them
727  for(int j = 0; j < pObject->numOfFaces; j++)
728  {
729  // Go through each corner of the triangle and draw it.
730  for(int whichVertex = 0; whichVertex < 3; whichVertex++)
731  {
732  // Get the index for each point of the face
733  int index = pObject->pFaces[j].vertIndex[whichVertex];
734 
735  // Give OpenGL the normal for this vertex.
736  glNormal3f(pObject->pNormals[ index ].x, pObject->pNormals[ index ].y, pObject->pNormals[ index ].z);
737 
738  // If the object has a texture associated with it, give it a texture coordinate.
739  if(pObject->bHasTexture) {
740 
741  // Make sure there was a UVW map applied to the object or else it won't have tex coords.
742  if(pObject->pTexVerts) {
743  //BYTE *pColor = Models[imodel]->pMaterials[pObject->materialID].color;
744 
745  // Assign the current color to this model
746  //glColor3ub(pColor[0]*state.tintr, pColor[1]*state.tintg, pColor[2]*state.tintb);
747  //glColor4ub( pColor[0]*state->tintr, pColor[1]*state->tintg, pColor[2]*state->tintb,255*state->alpha );
748 
749  MOubyte *pColor = Models[imodel]->pMaterials[pObject->materialID].colorDiffuse;
750 
751  // Assign the current color to this model
752  if (pColor!=NULL) {
753  float rf = (float)pColor[0] * state->tintr;
754  float rg = (float)pColor[1] * state->tintg;
755  float rb = (float)pColor[2] * state->tintb;
756  float af = 255.0 * state->alpha;
757  glColor4f( rf, rg, rb, af);
758  } else glColor4f(state->tintr, state->tintg, state->tintb,state->alpha);
759 
760  if ( MAT.texMaps.size()) {
761  x = pObject->pTexVerts[ index ].x * MAT.texMaps[0].vTile + MAT.texMaps[0].vOffset;
762  y = pObject->pTexVerts[ index ].y * MAT.texMaps[0].uTile + MAT.texMaps[0].uOffset;
763  } else {
764  x = pObject->pTexVerts[ index ].x;
765  y = pObject->pTexVerts[ index ].y;
766  }
767 
768  glTexCoord2f( x , y );
769  }
770  } else {
771 
772  // Make sure there is a valid material/color assigned to this object.
773  // You should always at least assign a material color to an object,
774  // but just in case we want to check the size of the material list.
775  // if the size is at least one, and the material ID != -1,
776  // then we have a valid material.
777  if(Models[imodel]->pMaterials.size() && pObject->materialID >= 0)
778  {
779  // Get and set the color that the object is, since it must not have a texture
780  MOubyte *pColor = Models[imodel]->pMaterials[pObject->materialID].colorDiffuse;
781 
782  // Assign the current color to this model
783  if ( pColor!=NULL) {
784  float rf = (float)pColor[0] * state->tintr;
785  float rg = (float)pColor[1] * state->tintg;
786  float rb = (float)pColor[2] * state->tintb;
787  float af = 255.0 * state->alpha;
788  glColor4f( rf, rg, rb, af);
789  } else glColor4f(state->tintr, state->tintg, state->tintb,state->alpha);
790  }
791  }
792 
793  // Pass in the current vertex of the object(Corner of current face)
794  glVertex3f(pObject->pVerts[ index ].x, pObject->pVerts[ index ].y, pObject->pVerts[ index ].z);
795  }
796  }
797 
798  glEnd(); // End the drawing
799 #endif
800  }
801 
802 
803 }
804 */
moSceneNode m_MotherNode
moText GetFullName()
Retreive full file name: return "myFileName" for "myFileName.txt".
virtual MOboolean Init()
#define MOulong
Definition: moTypes.h:392
void Error(moText p_text)
Anuncia y registra un error.
Definition: moAbstract.cpp:79
virtual ~moSceneNode()
virtual MOboolean Init()
Inicializa el objeto.
void SetName(const moText &p_name)
CVector3 * pVerts
virtual MOboolean Finish()
virtual void Draw(moEffectState *state, GLuint g_ViewMode)
#define MOboolean
Definition: moTypes.h:385
static MOulong CreateUID()
static MOulong UID
int vertIndex[3]
void MoldeoLogo(long ticks=0)
function x(bx)
Definition: jquery.js:30
void SetResourceType(moResourceType p_restype)
moSceneNode * m_pMoldeoLogo
moSceneNodePointerArray m_Childrens
moTextureManager * mTM
std::vector< mo3DSTextureMapInfo > texMaps
CVector2 * pTexVerts
moFile GetDataFile(const moText &p_file_name)
MOboolean Exists()
Definition: moFile.cpp:436
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
clase de para manejar textos
Definition: moText.h:75
virtual MOboolean Finish()
Finaliza el objeto, libera recursos.
moResourceManager * m_pResourceManager
Puntero al administrador de recursos.
MOulong GetId()
Dispositivo de entrada/salida, típicamente, interfaces humanas de IO y datos ( teclado, mouse, tableta, tcp, udp, serial )
Definition: moTypes.h:532
moGLMatrixf & MakeIdentity()
Definition: moGLManager.cpp:79
moGLMatrixf m_ModelMatrix
moTypes MOint moText moParamIndex moParamReference int iRow int int i int i
Definition: all_f.js:18
virtual void Interaction()
virtual void Interaction()
moSceneNode * Get3dModel(const moText &p_object_name, bool force_load=false)
virtual MOboolean Init()
Inicializa el objeto.
vector< mo3DSObject > pObject
CVector3 * pNormals
virtual moSceneNode * GetObjectByName(const moText &p_name)
void SetLabelName(const moText &p_labelname)
virtual moSceneNode * GetChild(int p_index_child)
virtual int RemoveChild(moSceneNodePointer p_child_node)
static moDebug * MODebug2
Clase de impresión de errores para depuración.
Definition: moAbstract.h:225
#define moDefineDynamicArray(name)
Definition: moArray.cpp:222
moDataManager * GetDataMan()
virtual moSceneNode * GetObjectById(MOulong p_id)
moSceneNode * Load3dModel(const moText &p_file_name)
const moText & GetName()
virtual void Update()
virtual void Draw(moEffectState *state, GLuint g_ViewMode)
mosFace * pFaces
#define MOuint
Definition: moTypes.h:387
vector< mo3DSMaterialInfo > pMaterials
LIBMOLDEO_API moText0 IntToStr(int a)
Definition: moText.cpp:1070
virtual int AddChild(moSceneNodePointer p_child_node)
moGLMatrixf m_ProjectionMatrix
moSceneNode & operator=(const moSceneNode &p_src)
moFile GetAppDataFile(const moText &p_file_name)
moSceneNode * m_Parent
void Message(moText p_text)
Anuncia un mensaje al usuario además de guardarlo en el log de texto.
Definition: moAbstract.cpp:114
void SetType(moMoldeoObjectType p_type)
#define MOubyte
Definition: moTypes.h:399
moTextureManager * GetTextureMan()
virtual const moText & ToJSON()