Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #include "xform-model.h"
00036
00037 #include "common/wave_ex.h"
00038 #include "perf/perf.h"
00039
00040
00041 namespace glut {
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059 class XformModel : public Renderable {
00060 public:
00061
00062 XformModel(void) throw();
00063 ~XformModel(void) throw() { }
00064
00065
00066 void initialize(IN const matrix4_t& xform,
00067 IN smart_ptr<Renderable>& model);
00068
00069
00070 rect3d_t getBoundingBox(void) const throw() { return m_bounds; }
00071 void render(IN const glut::render_context_t& rc,
00072 IN RenderQueue * rq);
00073 bool isAnimateable(void) const throw();
00074 void getAnimationState(OUT std::string &state);
00075 bool setAnimationState(IN const char * state);
00076 void getAnimationVerbs(OUT VecString& verbs);
00077 bool setAnimation(IN const char * verb);
00078
00079 private:
00080
00081
00082
00083
00084
00085 rect3d_t m_bounds;
00086 std::string m_timerName;
00087 matrix4_t m_xform;
00088 matrix4_t m_xformTranspose;
00089 smart_ptr<Renderable> m_model;
00090 };
00091
00092
00093
00094 XformModel::XformModel
00095 (
00096 void
00097 )
00098 throw()
00099 {
00100 }
00101
00102
00103
00104 void
00105 XformModel::initialize
00106 (
00107 IN const matrix4_t& xform,
00108 IN smart_ptr<Renderable>& model
00109 )
00110 {
00111 ASSERT(model, "null");
00112
00113 m_xform = xform;
00114 m_model = model;
00115
00116
00117 m_xformTranspose = m_xform;
00118 m_xformTranspose.transpose();
00119
00120
00121 m_bounds = model->getBoundingBox();
00122 }
00123
00124
00125
00126 void
00127 XformModel::render
00128 (
00129 IN const glut::render_context_t& rc,
00130 IN RenderQueue * rq
00131 )
00132 {
00133 perf::Timer timer(m_timerName.c_str());
00134 ASSERT(rq, "null");
00135 ASSERT(m_model, "null");
00136
00137
00138 glMatrixMode(GL_MODELVIEW);
00139 glPushMatrix();
00140
00141
00142 glMultMatrixf(m_xformTranspose.m);
00143
00144
00145 m_model->render(rc, rq);
00146
00147
00148 glMatrixMode(GL_MODELVIEW);
00149 glPopMatrix();
00150 }
00151
00152
00153
00154 bool
00155 XformModel::isAnimateable
00156 (
00157 void
00158 )
00159 const
00160 throw()
00161 {
00162 ASSERT(m_model, "null");
00163
00164 return m_model->isAnimateable();
00165 }
00166
00167
00168
00169 void
00170 XformModel::getAnimationState
00171 (
00172 OUT std::string &state
00173 )
00174 {
00175 ASSERT(m_model, "null");
00176
00177 m_model->getAnimationState(state);
00178 }
00179
00180
00181
00182 bool
00183 XformModel::setAnimationState
00184 (
00185 IN const char * state
00186 )
00187 {
00188 ASSERT(state, "null");
00189 ASSERT(m_model, "null");
00190
00191 return m_model->setAnimationState(state);
00192 }
00193
00194
00195
00196 void
00197 XformModel::getAnimationVerbs
00198 (
00199 OUT VecString& verbs
00200 )
00201 {
00202 ASSERT(m_model, "null");
00203
00204 return m_model->getAnimationVerbs(verbs);
00205 }
00206
00207
00208
00209 bool
00210 XformModel::setAnimation
00211 (
00212 IN const char * verb
00213 )
00214 {
00215 ASSERT(m_model, "null");
00216
00217 return m_model->setAnimation(verb);
00218 }
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234 smart_ptr<Renderable>
00235 createXformModel
00236 (
00237 IN const matrix4_t& xform,
00238 IN smart_ptr<Renderable>& model
00239 )
00240 {
00241 ASSERT(model, "null");
00242
00243 smart_ptr<XformModel> local = new XformModel;
00244 ASSERT(local, "out of memory");
00245
00246 local->initialize(xform, model);
00247
00248 return local;
00249 }
00250
00251
00252
00253 };
00254