Mondschein Engine  0.3.0
mondschein_core.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 "types.h"
22 #include "core/camera.h"
23 #include "core/light.h"
24 #include "core/material.h"
25 #include "core/mesh.h"
26 #include "core/pose.h"
27 #include "core/texture.h"
28 #include "core/scenegraph.h"
29 #include "core/beziercurve.h"
30 #include "core/bezierpatch.h"
31 #include "core/nurbscurve.h"
32 #include "core/nurbspatch.h"
33 
34 using namespace mondschein;
35 
36 scene::Camera_p Core::create_camera()
37 {
38  return scene::Camera_p(new scene::Camera());
39 }
40 
41 scene::Camera_p Core::create_camera(const std::string& _id,float64 _v,float64 _a,float64 _n,float64 _f,
42  float64 _x,float64 _y,float64 _w,float64 _h)
43 {
44  return scene::Camera_p(new scene::Camera(_id,scene::camera_attribs_t(_v,_a,_n,_f,_x,_y,_w,_h)));
45 }
46 
47 scene::Camera_p Core::create_camera(scene::Camera_c _c)
48 {
49  return scene::Camera_p(new scene::Camera(_c));
50 }
51 
52 scene::Light_p Core::create_light()
53 {
54  return scene::Light_p(new scene::Light());
55 }
56 
57 scene::Light_p Core::create_light(const std::string& _id,const Eigen::Vector4d &_a,const Eigen::Vector4d &_d,
58  const Eigen::Vector4d &_s,const Eigen::Vector4d &_p,const Eigen::Vector4d &_sd,
59  float64 _se,float64 _sc,float64 _ca,float64 _la,float64 _qa,uint8 _l)
60 {
61  return scene::Light_p(new scene::Light(_id,scene::light_attribs_t(_a,_d,_s,_p,_sd,_se,_sc,_ca,_la,_qa,_l)));
62 }
63 
64 scene::Light_p Core::create_light(scene::Light_c _l)
65 {
66  return scene::Light_p(new scene::Light(_l));
67 }
68 
69 scene::Material_p Core::create_material()
70 {
71  return scene::Material_p(new scene::Material());
72 }
73 
74 scene::Material_p Core::create_material(const std::string& _id,const Eigen::Vector4d &_a,const Eigen::Vector4d &_d,
75  const Eigen::Vector4d &_s,const Eigen::Vector4d &_e,float64 _sh)
76 {
77  return scene::Material_p(new scene::Material(_id,scene::material_attribs_t(_a,_d,_s,_e,_sh)));
78 }
79 
80 scene::Material_p Core::create_material(scene::Material_c _m)
81 {
82  return scene::Material_p(new scene::Material(_m));
83 }
84 
85 scene::Mesh_p Core::create_mesh()
86 {
87  return scene::Mesh_p(new scene::Mesh());
88 }
89 
90 scene::Mesh_p Core::create_mesh(const std::string& _id,const std::vector<Eigen::Vector4d> &_v,
91  const std::vector<Eigen::Vector3d> &_vn,const std::vector<Eigen::Vector4d> &_vt,
92  const std::vector<Eigen::Vector4d> &_vc)
93 {
94  return scene::Mesh_p(new scene::Mesh(_id,scene::mesh_attribs_t(_v,_vn,_vt,_vc)));
95 }
96 
97 scene::Mesh_p Core::create_mesh(scene::Mesh_c _m)
98 {
99  return scene::Mesh_p(new scene::Mesh(_m));
100 }
101 
102 scene::Pose_p Core::create_pose()
103 {
104  return scene::Pose_p(new scene::Pose());
105 }
106 
107 scene::Pose_p Core::create_pose(const std::string& _id,const Eigen::Matrix4d &_m)
108 {
109  return scene::Pose_p(new scene::Pose(_id,_m));
110 }
111 
112 scene::Pose_p Core::create_pose(scene::Pose_c _p)
113 {
114  return scene::Pose_p(new scene::Pose(_p));
115 }
116 
117 scene::Texture_p Core::create_texture()
118 {
119  return scene::Texture_p(new scene::Texture());
120 }
121 
122 scene::Texture_p Core::create_texture(const std::string& _id,uint32 _w,uint32 _h,uint8 _bpp,bool _f,
123  texture_filtering_e _tf,uint8 _af,uint8 _tu,const std::vector<uint8> &_d)
124 {
125  return scene::Texture_p(new scene::Texture(_id,scene::texture_attribs_t(_w,_h,_bpp,_f,_tf,_af,_tu,_d)));
126 }
127 
128 scene::Texture_p Core::create_texture(scene::Texture_c _t)
129 {
130  return scene::Texture_p(new scene::Texture(_t));
131 }
132 
133 scene::Scenegraph_p Core::create_scenegraph()
134 {
135  return scene::Scenegraph_p(new scene::Scenegraph());
136 }
137 
138 scene::Scenegraph_p Core::create_scenegraph(const std::vector<scene::Scenenode_c> &_n,
139  const boost::adjacency_list<> &_e)
140 {
141  return scene::Scenegraph_p(new scene::Scenegraph(scene::scenegraph_attribs_t(_n,_e)));
142 }
143 
144 scene::Scenegraph_p Core::create_scenegraph(scene::Scenegraph_c _sg)
145 {
146  return scene::Scenegraph_p(new scene::Scenegraph(_sg));
147 }
148 
149 math::Beziercurve_p Core::create_beziercurve()
150 {
151  return math::Beziercurve_p(new math::Beziercurve());
152 }
153 
154 math::Beziercurve_p Core::create_beziercurve(const std::vector<Eigen::Vector4d> &_p)
155 {
156  return math::Beziercurve_p(new math::Beziercurve(_p));
157 }
158 
159 math::Beziercurve_p Core::create_beziercurve(math::Beziercurve_c _c)
160 {
161  return math::Beziercurve_p(new math::Beziercurve(_c));
162 }
163 
164 math::Bezierpatch_p Core::create_bezierpatch()
165 {
166  return math::Bezierpatch_p(new math::Bezierpatch());
167 }
168 
169 math::Bezierpatch_p Core::create_bezierpatch(const std::vector<math::Beziercurve_p> &_c)
170 {
171  return math::Bezierpatch_p(new math::Bezierpatch(_c));
172 }
173 
174 math::Bezierpatch_p Core::create_bezierpatch(math::Bezierpatch_c _p)
175 {
176  return math::Bezierpatch_p(new math::Bezierpatch(_p));
177 }
178 
179 math::NURBScurve_p Core::create_nurbscurve()
180 {
181  return math::NURBScurve_p(new math::NURBScurve());
182 }
183 
184 math::NURBScurve_p Core::create_nurbscurve(uint32 _d,const std::vector<Eigen::Vector4d> &_p, bool _cl)
185 {
186  math::NURBScurve_p c(new math::NURBScurve(_d,_p));
187  c->calc_knots(_cl);
188  return c;
189 }
190 
191 math::NURBScurve_p Core::create_nurbscurve(math::NURBScurve_c _c)
192 {
193  return math::NURBScurve_p(new math::NURBScurve(_c));
194 }
195 
196 math::NURBSpatch_p Core::create_nurbspatch()
197 {
198  return math::NURBSpatch_p(new math::NURBSpatch());
199 }
200 
201 math::NURBSpatch_p Core::create_nurbspatch(uint32 _d,const std::vector<math::NURBScurve_p> &_c,bool _cl)
202 {
203  math::NURBSpatch_p p(new math::NURBSpatch(_d,_c));
204  p->calc_knots(_cl);
205  return p;
206 }
207 
208 math::NURBSpatch_p Core::create_nurbspatch(math::NURBSpatch_c _p)
209 {
210  return math::NURBSpatch_p(new math::NURBSpatch(_p));
211 }