Example #1
0
/*! Inverse Operation of \c cirf_getSub(). */
inline void
getRel(const box& a, const cirf& b, cirf& ba)
{
    vec2f ad; box_rdDim(a, &ad);
    vec2f_set(&ba.c, (b.c(0) - a.l(0)) / ad(0), (b.c(1) - a.l(1)) / ad(1));
    ba.r() = b.r() / mean(ad(0), ad(1));
    if (ad(0) != ad(1)) {
        PTODO("ad(0) != ad(1) => may result in an ellipse\n");
    }
}
Example #2
0
/*! Sub-Circle when \p ba is viewed relative to \p a.
 * The inverse operation of \c cirf_getRel().
 */
inline void
getSub(const box& a, const cirf& ba, cirf& b)
{
    vec2f ad; box_rdDim(a, &ad);
    vec2f_set(&b.c, a.l(0) + ad(0) * ba.c(0), a.l(1) + ad(1) * ba.c(1));
    b.r() = ba.r() * mean(ad(0), ad(1));
    if (ad(0) != ad(1)) {
        PTODO("ad(0) != ad(1) => may result in an ellipse\n");
    }
}
Example #3
0
Sprite::Sprite(vec2f pos, vec2f dim, const char* textureName)
	: Renderable(RENDER_MODE_TRIANGLES, SHADER_ATTRIBFLAG_POS | SHADER_ATTRIBFLAG_COL | SHADER_ATTRIBFLAG_TEX)
{
	vec2f_copy(this->dim, dim);
	vec2f_copy(this->pos, pos);
	vec2f_set(scale, 1.f, 1.f);
	rotation = 0.f;

	texture = Texture::loadTexture(textureName);
	texture->upload();

	currentShader = Renderer::getInstance()->texture;

	allocate(6);

	vertpos(-dim[X] / 2.f, -dim[Y] / 2.f);
	vertcol(1.f, 1.f, 1.f, 1.f);
	verttex(0.f, 0.f);
	vertpos(-dim[X] / 2.f, dim[Y] / 2.f);
	vertcol(1.f, 1.f, 1.f, 1.f);
	verttex(0.f, 1.f);
	vertpos(dim[X] / 2.f, dim[Y] / 2.f);
	vertcol(1.f, 1.f, 1.f, 1.f);
	verttex(1.f, 1.f);

	vertpos(-dim[X] / 2.f, -dim[Y] / 2.f);
	vertcol(1.f, 1.f, 1.f, 1.f);
	verttex(0.f, 0.f);
	vertpos(dim[X] / 2.f, dim[Y] / 2.f);
	vertcol(1.f, 1.f, 1.f, 1.f);
	verttex(1.f, 1.f);
	vertpos(dim[X] / 2.f, -dim[Y] / 2.f);
	vertcol(1.f, 1.f, 1.f, 1.f);
	verttex(1.f, 0.f);

	upload();
}
Example #4
0
Tile::Tile(bool collision, float u_topleft, float v_topleft, float u_botright, float v_botright)
	: collision {collision}
{
	vec2f_set(uv_topleft, u_topleft, v_topleft);
	vec2f_set(uv_botright, u_botright, v_botright);
}