Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Scene.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2011 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 /*
19  * File : Scene.cpp
20  * Project : graphics
21  * Description : This file contains default implementations and utilities
22  * : to be used together with the Scene interface and related
23  * : classes.
24  *
25  * @note This file would fit just as well into the graphics/ subdirectory.
26  */
27 
28 #include "precompiled.h"
29 
30 #include "graphics/Model.h"
32 #include "renderer/Scene.h"
33 
34 ///////////////////////////////////////////////////////////
35 // Default implementation traverses the model recursively and uses
36 // SubmitNonRecursive for the actual work.
38 {
39  if (model->ToCModel())
40  {
41  SubmitNonRecursive(model->ToCModel());
42 
43  const std::vector<CModel::Prop>& props = model->ToCModel()->GetProps();
44  for (size_t i = 0; i < props.size(); i++)
45  {
46  if (!props[i].m_Hidden)
47  SubmitRecursive(props[i].m_Model);
48  }
49  }
50  else if (model->ToCModelDecal())
51  {
52  Submit(model->ToCModelDecal());
53  }
54  else if (model->ToCModelParticleEmitter())
55  {
56  Submit(model->ToCModelParticleEmitter()->m_Emitter.get());
57  }
58  else
59  debug_warn(L"unknown model type");
60 }
CParticleEmitterPtr m_Emitter
virtual CModelParticleEmitter * ToCModelParticleEmitter()
Dynamic cast.
Definition: ModelAbstract.h:82
virtual void SubmitRecursive(CModelAbstract *model)
Submit a model that is part of the scene, including attached sub-models.
Definition: Scene.cpp:37
std::vector< Prop > & GetProps()
Definition: Model.h:240
virtual void SubmitNonRecursive(CModel *model)=0
Submit a model that is part of the scene, without submitting attached models.
Abstract base class for graphical objects that are used by units, or as props attached to other CMode...
Definition: ModelAbstract.h:36
static size_t model
Definition: x86_x64.cpp:211
virtual CModel * ToCModel()
Dynamic cast.
Definition: ModelAbstract.h:76
#define debug_warn(expr)
display the error dialog with the given text.
Definition: debug.h:324
virtual void Submit(CPatch *patch)=0
Submit a terrain patch that is part of the scene.
virtual CModelDecal * ToCModelDecal()
Dynamic cast.
Definition: ModelAbstract.h:79