}
-Animation::Loader::Loader(Animation &a):
- DataFile::CollectionObjectLoader<Animation>(a, 0)
+Animation::Loader::Loader(Animation &a, Collection *c):
+ DataFile::CollectionObjectLoader<Animation>(a, c),
+ start_slope(1),
+ end_slope(1),
+ slopes_set(0)
{
- init();
-}
-
-Animation::Loader::Loader(Animation &a, Collection &c):
- DataFile::CollectionObjectLoader<Animation>(a, &c)
-{
- init();
-}
-
-void Animation::Loader::init()
-{
- start_slope = 1;
- end_slope = 1;
- slopes_set = 0;
add("armature", &Animation::armature);
add("control_keyframe", &Loader::control_keyframe);
add("control_keyframe", &Loader::control_keyframe_inline);
int slopes_set;
public:
- Loader(Animation &);
- Loader(Animation &, Collection &);
+ Loader(Animation &a): Loader(a, 0) { }
+ Loader(Animation &a, Collection &c): Loader(a, &c) { }
private:
- void init();
+ Loader(Animation &, Collection *);
virtual void finish();
void check_slopes_and_control(bool, bool);
}
-KeyFrame::Loader::Loader(KeyFrame &k):
- DataFile::CollectionObjectLoader<KeyFrame>(k, 0)
-{
- init();
-}
-
-KeyFrame::Loader::Loader(KeyFrame &k, Collection &c):
- DataFile::CollectionObjectLoader<KeyFrame>(k, &c)
-{
- init();
-}
-
-void KeyFrame::Loader::init()
+KeyFrame::Loader::Loader(KeyFrame &k, Collection *c):
+ DataFile::CollectionObjectLoader<KeyFrame>(k, c)
{
add("pose", &Loader::pose);
add("pose", &Loader::pose_inline);
std::string inline_base_name;
public:
- Loader(KeyFrame &);
- Loader(KeyFrame &, Collection &);
+ Loader(KeyFrame &k): Loader(k, 0) { }
+ Loader(KeyFrame &k, Collection &c): Loader(k, &c) { }
private:
- void init();
+ Loader(KeyFrame &, Collection *);
public:
void set_inline_base_name(const std::string &);
{ }
-Font::Loader::Loader(Font &f):
- DataFile::CollectionObjectLoader<Font>(f, 0)
-{
- init();
-}
-
-Font::Loader::Loader(Font &f, Collection &c):
- DataFile::CollectionObjectLoader<Font>(f, &c)
-{
- init();
-}
-
-void Font::Loader::init()
+Font::Loader::Loader(Font &f, Collection *c):
+ DataFile::CollectionObjectLoader<Font>(f, c)
{
add("native_size", &Font::native_size);
add("ascent", &Font::ascent);
class Loader: public DataFile::CollectionObjectLoader<Font>
{
public:
- Loader(Font &);
- Loader(Font &, Collection &);
-
+ Loader(Font &f): Loader(f, 0) { }
+ Loader(Font &f, Collection &c): Loader(f, &c) { }
private:
- void init();
+ Loader(Font &, Collection *);
+
void glyph(unsigned);
void kerning(unsigned, unsigned, float);
void ligature(unsigned, unsigned, unsigned);
namespace GL {
GridBuilder::GridBuilder(float w, float h, unsigned u, unsigned v):
- origin(-w/2, -h/2, 0),
- side1(w, 0, 0),
- side2(0, h, 0),
- norm(0, 0, 1),
- binorm(0, 1, 0),
- u_div(u),
- v_div(v)
-{
- init(false);
-}
+ GridBuilder(Vector3(-w/2, -h/2, 0), Vector3(w, 0, 0), Vector3(0, h, 0), u, v)
+{ }
GridBuilder::GridBuilder(const Vector3 &o, const Vector3 &s, unsigned u, unsigned v):
- origin(o),
- u_div(u),
- v_div(v)
-{
- if(abs(s.z)<abs(s.x) && abs(s.z)<abs(s.y))
- {
- side1 = Vector3(s.x, 0, 0);
- side2 = Vector3(0, s.y, 0);
- }
- else if(abs(s.y)<abs(s.x))
- {
- side1 = Vector3(0, 0, s.z);
- side2 = Vector3(s.x, 0, 0);
- }
- else
- {
- side1 = Vector3(0, s.y, 0);
- side2 = Vector3(0, 0, s.z);
- }
- init(true);
-}
+ GridBuilder(o, get_side(s, 0), get_side(s, 1), u, v)
+{ }
GridBuilder::GridBuilder(const Vector3 &o, const Vector3 &s1, const Vector3 &s2, unsigned u, unsigned v):
origin(o),
side1(s1),
side2(s2),
- u_div(u),
- v_div(v)
+ u_div(max(u, 1U)),
+ v_div(max(v, 1U))
{
- init(true);
+ norm = normalize(cross(side1, side2));
+ binorm = normalize(cross(norm, side1));
}
-void GridBuilder::init(bool compute_normals)
+Vector3 GridBuilder::get_side(const Vector3 &size, unsigned index)
{
- if(u_div<1)
- u_div = 1;
- if(v_div<1)
- v_div = 1;
-
- if(compute_normals)
- {
- norm = normalize(cross(side1, side2));
- binorm = normalize(cross(norm, side1));
- }
+ if(!size.x)
+ return Vector3(0, (index==0 ? size.y : 0), (index==1 ? size.z : 0));
+ else if(!size.y)
+ return Vector3((index==0 ? size.x : 0), 0, (index==1 ? size.z : 0));
+ else
+ return Vector3((index==0 ? size.x : 0), (index==1 ? size.z : 0), 0);
}
void GridBuilder::build(PrimitiveBuilder &builder) const
GridBuilder(const Vector3 &, const Vector3 &, unsigned = 4, unsigned = 4);
GridBuilder(const Vector3 &, const Vector3 &, const Vector3 &, unsigned = 4, unsigned = 4);
private:
- void init(bool);
+ Vector3 get_side(const Vector3 &, unsigned);
public:
using GeometryBuilder::build;
}
-SequenceTemplate::Step::Loader::Loader(Step &p):
- DataFile::CollectionObjectLoader<Step>(p, 0)
-{
- init();
-}
-
-SequenceTemplate::Step::Loader::Loader(Step &p, Collection &c):
- DataFile::CollectionObjectLoader<Step>(p, &c)
-{
- init();
-}
-
-void SequenceTemplate::Step::Loader::init()
+SequenceTemplate::Step::Loader::Loader(Step &p, Collection *c):
+ DataFile::CollectionObjectLoader<Step>(p, c)
{
add("blend", &Loader::blend);
add("blend", &Loader::blend_factors);
std::string inline_base_name;
public:
- Loader(Step &);
- Loader(Step &, Collection &);
+ Loader(Step &s): Loader(s, 0) { }
+ Loader(Step &s, Collection &c): Loader(s, &c) { }
private:
+ Loader(Step &, Collection *);
void init();
public:
}
Framebuffer::Framebuffer():
- FramebufferBackend(false)
-{
- init();
-}
+ FramebufferBackend(false),
+ width(0),
+ height(0),
+ dirty(0)
+{ }
Framebuffer::Framebuffer(FrameAttachment fa):
- FramebufferBackend(false)
+ Framebuffer()
{
- init();
set_format(fa);
}
Framebuffer::Framebuffer(const FrameFormat &f):
- FramebufferBackend(false)
+ Framebuffer()
{
- init();
set_format(f);
}
-void Framebuffer::init()
-{
- width = 0;
- height = 0;
- dirty = 0;
-}
-
void Framebuffer::set_format(const FrameFormat &fmt)
{
if(!format.empty() || !id)
/** Creates a framebuffer and sets its format. */
Framebuffer(const FrameFormat &);
-private:
- void init();
-
-public:
/** Sets the format of the framebuffer. Once the format is set, it can't
be changed. */
void set_format(const FrameFormat &);
namespace Msp {
namespace GL {
-Mesh::Mesh(ResourceManager *rm)
+Mesh::Mesh(ResourceManager *rm):
+ vbuf(0),
+ ibuf(0),
+ dirty(0),
+ disallow_rendering(false),
+ face_winding(NON_MANIFOLD)
{
- init(rm);
+ if(rm)
+ set_manager(rm);
}
-Mesh::Mesh(const VertexFormat &f, ResourceManager *rm)
+Mesh::Mesh(const VertexFormat &f, ResourceManager *rm):
+ Mesh(rm)
{
- init(rm);
storage(f);
}
-void Mesh::init(ResourceManager *rm)
-{
- vbuf = 0;
- ibuf = 0;
- dirty = 0;
- disallow_rendering = false;
- face_winding = NON_MANIFOLD;
-
- if(rm)
- set_manager(rm);
-}
-
Mesh::~Mesh()
{
set_manager(0);
public:
Mesh(ResourceManager * = 0);
Mesh(const VertexFormat &, ResourceManager * = 0);
-private:
- void init(ResourceManager *);
-public:
~Mesh();
void storage(const VertexFormat &);
}
-Texture::Loader::Loader(Texture &t):
- DataFile::CollectionObjectLoader<Texture>(t, 0)
+Texture::Loader::Loader(Texture &t, Collection *c):
+ CollectionObjectLoader<Texture>(t, c),
+ levels(0)
{
- init();
-}
-
-Texture::Loader::Loader(Texture &t, Collection &c):
- DataFile::CollectionObjectLoader<Texture>(t, &c)
-{
- init();
-}
-
-void Texture::Loader::init()
-{
- levels = 0;
-
add("external_image", &Loader::external_image);
add("external_image_srgb", &Loader::external_image_srgb);
add("generate_mipmap", &Loader::generate_mipmap);
unsigned levels;
public:
- Loader(Texture &);
- Loader(Texture &, Collection &);
+ Loader(Texture &t): Loader(t, 0) { }
+ Loader(Texture &t, Collection &c): Loader(t, &c) { }
private:
- void init();
+ Loader(Texture &, Collection *);
virtual void finish();
namespace GL {
EnvironmentMap::EnvironmentMap(unsigned s, PixelFormat f, Renderable &r, Renderable &e):
- Effect(r),
- environment(e),
- irradiance_shprog(Resources::get_global().get<Program>("_envmap_irradiance.glsl.shader")),
- specular_shprog(Resources::get_global().get<Program>("_envmap_specular.glsl.shader")),
- fullscreen_mesh(Resources::get_global().get<Mesh>("_fullscreen_quad.mesh")),
- sampler(Resources::get_global().get<Sampler>("_linear_clamp.samp")),
- mip_sampler(Resources::get_global().get<Sampler>("_mip_clamp.samp"))
-{
- init(s, f, 1);
-}
+ EnvironmentMap(s, f, 1, r, e)
+{ }
EnvironmentMap::EnvironmentMap(unsigned s, PixelFormat f, unsigned l, Renderable &r, Renderable &e):
Effect(r),
fullscreen_mesh(Resources::get_global().get<Mesh>("_fullscreen_quad.mesh")),
sampler(Resources::get_global().get<Sampler>("_linear_clamp.samp")),
mip_sampler(Resources::get_global().get<Sampler>("_mip_clamp.samp"))
-{
- init(s, f, l);
-}
-
-void EnvironmentMap::init(unsigned s, PixelFormat f, unsigned l)
{
if(!l || (1U<<(l-1))>=s)
throw invalid_argument("EnvironmentMap::EnvironmentMap");
public:
EnvironmentMap(unsigned size, PixelFormat, Renderable &rend, Renderable &env);
EnvironmentMap(unsigned size, PixelFormat, unsigned, Renderable &rend, Renderable &env);
-private:
- void init(unsigned, PixelFormat, unsigned);
-public:
void set_depth_clip(float, float);
/** Sets the interval in frames between environment map updates. A value of
}
-Object::Loader::Loader(Object &o):
- LodLoader(o, 0, 0)
-{
- init();
-}
-
-Object::Loader::Loader(Object &o, Collection &c):
- LodLoader(o, 0, &c)
-{
- init();
-}
-
-void Object::Loader::init()
+Object::Loader::Loader(Object &o, Collection *c):
+ LodLoader(o, 0, c)
{
add("bounding_sphere_hint", &Loader::bounding_sphere_hint);
add("level_of_detail", &Loader::level_of_detail);
class Loader: public LodLoader
{
public:
- Loader(Object &);
- Loader(Object &, Collection &);
+ Loader(Object &o): Loader(o, 0) { }
+ Loader(Object &o, Collection &c): Loader(o, &c) { }
private:
- void init();
+ Loader(Object &, Collection *);
virtual void finish();
void bounding_sphere_hint(float, float, float, float);
}
-Scene::Loader::Loader(Scene &s, Collection &c):
+Scene::Loader::Loader(Scene &s, Collection &c, ContentMap *m):
DataFile::CollectionObjectLoader<Scene>(s, &c),
- content(0)
+ content(m),
+ inst_counter(0)
{
- init();
-}
-
-Scene::Loader::Loader(Scene &s, Collection &c, ContentMap &m):
- DataFile::CollectionObjectLoader<Scene>(s, &c),
- content(&m)
-{
- init();
-}
-
-void Scene::Loader::init()
-{
- inst_counter = 0;
-
add("object", &Loader::object);
add("object", &Loader::object_tagged);
add("scene", &Loader::scene);
unsigned inst_counter;
public:
- Loader(Scene &, Collection &);
- Loader(Scene &, Collection &, ContentMap &);
+ Loader(Scene &s, Collection &c): Loader(s, c, 0) { }
+ Loader(Scene &s, Collection &c, ContentMap &m) : Loader(s, c, &m) { }
private:
- void init();
+ Loader(Scene &, Collection &, ContentMap *);
void object(const std::string &);
void object_tagged(const std::string &, const std::string &);