Mondschein Engine  0.3.0
pose.cpp
1 /* Mondschein Engine is a fast, powerful, and easy-to-use 3D realtime rendering engine.
2  *
3  * Copyright (C) 2009-2013 by Andreas Amereller
4  * E-Mail: andreas.amereller.dev@googlemail.com
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by the Free
8  * Software Foundation; either version 3 of the License, or (at your option)
9  * any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include "gl13/pose.h"
22 #include "core/pose.h"
23 #include <GL/gl.h>
24 
25 using namespace mondschein;
26 using namespace renderer;
27 
28 GL13_Pose::GL13_Pose() : Renderable(), pose()
29 {
30  return;
31 }
32 
33 GL13_Pose::GL13_Pose(const std::array<float64,16> &_p) : Renderable(), pose(_p)
34 {
35  return;
36 }
37 
38 GL13_Pose::~GL13_Pose()
39 {
40  return;
41 }
42 
43 void GL13_Pose::set_pose(const std::array<float64,16> &_p)
44 {
45  pose=_p;
46  return;
47 }
48 
49 std::array<float64,16> GL13_Pose::get_pose() const
50 {
51  return pose;
52 }
53 
54 void GL13_Pose::create_pose(scene::Scenenode_c _sn)
55 {
56  scene::Pose_c p=boost::dynamic_pointer_cast<const scene::Pose>(_sn);
57  if (p.get()==NULL)
58  {
59  std::string err("Mondschein Engine ERROR: Scenenode is not a pose. ");
60  err+="Exception raised in function\n\t";
61  err+="void mondschein::renderer::GL13_Pose::create_pose(mondschein::scene::Scenenode_c _sn)";
62  throw boost::enable_current_exception(exception()) << exception_error(err);
63  }
64  for (uint32 i=0; i<16; ++i) pose.at(i)=p->get_matrix()(i%4,i/4);
65  return;
66 }
67 
68 void GL13_Pose::render() const
69 {
70  glMatrixMode(GL_MODELVIEW);
71  glMultMatrixd(pose.data());
72  return;
73 }