Example #1
0
HueSprite::HueSprite()
{
	m_hue = 0.f;
	updateMatrix();
}
Example #2
0
void HueSprite::setHue(float hue)
{
	m_hue = hue;

	updateMatrix();
}
Example #3
0
void Transformation::update()
{
    updateParameter();
    updateMatrix();
}
Example #4
0
Transformation::Transformation(int type,
                               unordered_map<string, Parameter> *params,
                               string input1,
                               string input2)
{
    this -> type = type;
    this -> params = params;
    string nextExpression = "";
    bool expressionMode = false;
    string number = "";
    int i = 0;
    for(char& c : (input1 + " " + input2))
    {
        if(c == '{')
        {
            expressionMode = true;
        }
        else if(c == '}')
        {
            expressionMode = false;
            switch(i)
            {
            case 0:
                x_expr = nextExpression.substr(5);
                x = evaluate_transformation_expression(x_expr, params, this);
                break;
            case 1:
                y_expr = nextExpression.substr(5);
                y = evaluate_transformation_expression(y_expr, params, this);
                break;
            case 2:
                z_expr = nextExpression.substr(5);
                z = evaluate_transformation_expression(z_expr, params, this);
                break;
            case 3:
                w_expr = nextExpression.substr(5);
                w = evaluate_transformation_expression(w_expr, params, this);
                break;
            }
            nextExpression = "";
            i++;
        }
        else if(expressionMode)
        {
            nextExpression.push_back(c);
        }
        else if(!expressionMode && ((c >= '0' &&  c <= '9') || c == '.' || c == '-' || c == '+'))
        {
            number.push_back(c);
        }
        else
        {
            if(number != "")
            {
                switch(i)
                {
                case 0:
                    x = stof(number);
                    break;
                case 1:
                    y = stof(number);
                    break;
                case 2:
                    z = stof(number);
                    break;
                case 3:
                    w = stof(number);
                    break;
                }
                number = "";
                i++;
            }
        }
    }
    if(number != "")
    {
        switch(i)
        {
        case 0:
            x = stof(number);
            break;
        case 1:
            y = stof(number);
            break;
        case 2:
            z = stof(number);
            break;
        case 3:
            w = stof(number);
            break;
        }
    }
    isParametric = (x_expr != "" ||
                    y_expr != "" ||
                    z_expr != "" ||
                    w_expr != "");
    updateMatrix();
}
void Self::draw(cocos2d::Renderer* renderer, const cocos2d::Mat4& transform,
                std::uint32_t flags) {
    updateMatrix();
    Super::draw(renderer, transform, flags);
}
Example #6
0
void OpenGLESRenderTarget::unprojectPoint(const GeometryBuffer& buff,
    const glm::vec2& p_in, glm::vec2& p_out) const
{
    if (!d_matrixValid)
        updateMatrix();

    const OpenGLESGeometryBuffer& gb =
        static_cast<const OpenGLESGeometryBuffer&>(buff);

    const GLint vp[4] = {
        static_cast<GLint>(d_area.left()),
        static_cast<GLint>(d_area.top()),
        static_cast<GLint>(d_area.getWidth()),
        static_cast<GLint>(d_area.getHeight())
    };

    GLdouble in_x, in_y, in_z = 0.0;

    // unproject the ends of the ray
    GLdouble r1_x, r1_y, r1_z;
    GLdouble r2_x, r2_y, r2_z;
    in_x = vp[2] * 0.5;
    in_y = vp[3] * 0.5;
    in_z = -d_viewDistance;

	double gb_matrixd[16], d_matrixd[16];
	for ((unsigned int i = 0; i < 16; ++i)
	{
		gb_matrixd[i] = (double)gb.getMatrix()[i];
		d_matrixd[i] = (double)d_matrix[i];
	}

    gluUnProject(in_x, in_y, in_z, gb_matrixd, d_matrixd, vp,
                 &r1_x, &r1_y, &r1_z);
    in_x = p_in.d_x;
    in_y = vp[3] - p_in.d_y;
    in_z = 0.0;
    gluUnProject(in_x, in_y, in_z, gb_matrixd, d_matrixd, vp,
                 &r2_x, &r2_y, &r2_z);

    // project points to orientate them with GeometryBuffer plane
    GLdouble p1_x, p1_y, p1_z;
    GLdouble p2_x, p2_y, p2_z;
    GLdouble p3_x, p3_y, p3_z;
    in_x = 0.0;
    in_y = 0.0;
    gluProject(in_x, in_y, in_z, gb_matrixd, d_matrixd, vp,
               &p1_x, &p1_y, &p1_z);
    in_x = 1.0;
    in_y = 0.0;
    gluProject(in_x, in_y, in_z, gb_matrixd, d_matrixd, vp,
               &p2_x, &p2_y, &p2_z);
    in_x = 0.0;
    in_y = 1.0;
    gluProject(in_x, in_y, in_z, gb_matrixd, d_matrixd, vp,
               &p3_x, &p3_y, &p3_z);

    // calculate vectors for generating the plane
    const double pv1_x = p2_x - p1_x;
    const double pv1_y = p2_y - p1_y;
    const double pv1_z = p2_z - p1_z;
    const double pv2_x = p3_x - p1_x;
    const double pv2_y = p3_y - p1_y;
    const double pv2_z = p3_z - p1_z;
    // given the vectors, calculate the plane normal
    const double pn_x = pv1_y * pv2_z - pv1_z * pv2_y;
    const double pn_y = pv1_z * pv2_x - pv1_x * pv2_z;
    const double pn_z = pv1_x * pv2_y - pv1_y * pv2_x;
    // calculate plane
    const double pn_len = std::sqrt(pn_x * pn_x + pn_y * pn_y + pn_z * pn_z);
    const double pl_a = pn_x / pn_len;
    const double pl_b = pn_y / pn_len;
    const double pl_c = pn_z / pn_len;
    const double pl_d = -(p1_x * pl_a + p1_y * pl_b + p1_z * pl_c);
    // calculate vector of picking ray
    const double rv_x = r1_x - r2_x;
    const double rv_y = r1_y - r2_y;
    const double rv_z = r1_z - r2_z;
    // calculate intersection of ray and plane
    const double pn_dot_r1 = (r1_x * pn_x + r1_y * pn_y + r1_z * pn_z);
    const double pn_dot_rv = (rv_x * pn_x + rv_y * pn_y + rv_z * pn_z);
    const double tmp1 = pn_dot_rv != 0.0 ? (pn_dot_r1 + pl_d) / pn_dot_rv : 0.0;
    const double is_x = r1_x - rv_x * tmp1;
    const double is_y = r1_y - rv_y * tmp1;

    p_out.d_x = static_cast<float>(is_x);
    p_out.d_y = static_cast<float>(is_y);
}
Example #7
0
void MazeSequential::step()
{	     
    // Update the real maze
    updateState(m_matrix, m_dest, 0, (m_matrix->width * m_matrix->height)-1);
    updateMatrix();
}
float DisplayList::getPivotY() {
    updateMatrix();
    return mPivotY;
}
Example #9
0
void IrrlichtRenderTarget::unprojectPoint(const GeometryBuffer& buff,
                                             const glm::vec& p_in,
                                             glm::vec& p_out) const
{
    if (!d_matrixValid)
        updateMatrix();

    const IrrlichtGeometryBuffer& gb =
        static_cast<const IrrlichtGeometryBuffer&>(buff);

    const irr::f32 midx = d_area.getWidth() * 0.5f;
    const irr::f32 midy = d_area.getHeight() * 0.5f;

    // viewport matrix
    const irr::f32 vpmat_[] =
    {
        midx, 0, 0, 0,
        0, -midy, 0, 0,
        0, 0, 1, 0,
        d_area.left() + midx, d_area.top() + midy, 0, 1
    };
    irr::core::matrix4 vpmat;
    vpmat.setM(vpmat_);

    // matrices used for projecting and unprojecting points
    const irr::core::matrix4 proj(gb.getMatrix() * d_matrix * vpmat);
    irr::core::matrix4 unproj(proj);
    unproj.makeInverse();

    irr::core::vector3df in;

    // unproject the ends of the ray
    in.X = midx;
    in.Y = midy;
    in.Z = -d_viewDistance;
    irr::core::vector3df r1;
    unproj.transformVect(r1, in);
    in.X = p_in.d_x;
    in.Y = p_in.d_y;
    in.Z = 0;
    irr::core::vector3df r2;
    unproj.transformVect(r2, in);
    // calculate vector of picking ray
    const irr::core::vector3df rv(r1 - r2);

    // project points to orientate them with GeometryBuffer plane
    in.X = 0.0;
    in.Y = 0.0;
    irr::core::vector3df p1;
    proj.transformVect(p1, in);
    in.X = 1.0;
    in.Y = 0.0;
    irr::core::vector3df p2;
    proj.transformVect(p2, in);
    in.X = 0.0;
    in.Y = 1.0;
    irr::core::vector3df p3;
    proj.transformVect(p3, in);

    // calculate the plane normal
    const irr::core::vector3df pn((p2 - p1).crossProduct(p3 - p1));
    // calculate distance from origin
    const irr::f32 plen = pn.getLength();
    const irr::f32 dist = -(p1.X * (pn.X / plen) +
                            p1.Y * (pn.Y / plen) +
                            p1.Z * (pn.Z / plen));

    // calculate intersection of ray and plane
    const irr::f32 pn_dot_rv = pn.dotProduct(rv);
    const irr::f32 tmp = pn_dot_rv != 0.0 ?
                            (pn.dotProduct(r1) + dist) / pn_dot_rv :
                             0.0f;

    p_out.d_x = static_cast<float>(r1.X - rv.X * tmp) * d_viewDistance;
    p_out.d_y = static_cast<float>(r1.Y - rv.Y * tmp) * d_viewDistance;
}
//----------------------------------------------------------------------------//
void IrrlichtGeometryBuffer::draw() const
{
    // Set up clipping for this buffer
    //
    // NB: This is done via viewport & projection manipulation because Irrlicht
    // does not expose scissoring facilities of underlying APIs.  This has the
    // unfortunate side effect of being much more expensive to set up.
    const irr::core::rect<irr::s32> target_vp(d_driver.getViewPort());
    const irr::core::matrix4 proj
        (d_driver.getTransform(irr::video::ETS_PROJECTION));

    const Size csz(d_clipRect.getSize());
    const Size tsz(static_cast<float>(target_vp.getWidth()),
                   static_cast<float>(target_vp.getHeight()));

    // set modified projection 'scissor' matix that negates scale and
    // translation that would be done by setting the viewport to the clip area.
    irr::core::matrix4 scsr(irr::core::matrix4::EM4CONST_IDENTITY);
    scsr(0, 0) = tsz.d_width / csz.d_width;
    scsr(1, 1) = tsz.d_height / csz.d_height;
    scsr(3, 0) = d_xViewDir * (tsz.d_width + 2.0f *
                   (target_vp.UpperLeftCorner.X -
                     (d_clipRect.d_left + csz.d_width * 0.5f))) / csz.d_width;
    scsr(3, 1) = -(tsz.d_height + 2.0f *
                   (target_vp.UpperLeftCorner.Y -
                     (d_clipRect.d_top + csz.d_height * 0.5f))) / csz.d_height;
    scsr *= proj;
    d_driver.setTransform(irr::video::ETS_PROJECTION, scsr);

    // set new viewport for the clipping area
    const irr::core::rect<irr::s32> vp(
            static_cast<irr::s32>(d_clipRect.d_left),
            static_cast<irr::s32>(d_clipRect.d_top),
            static_cast<irr::s32>(d_clipRect.d_right),
            static_cast<irr::s32>(d_clipRect.d_bottom));
    d_driver.setViewPort(vp);

    if (!d_matrixValid)
        updateMatrix();

    d_driver.setTransform(irr::video::ETS_WORLD, d_matrix);

    const int pass_count = d_effect ? d_effect->getPassCount() : 1;
    for (int pass = 0; pass < pass_count; ++pass)
    {
        // set up RenderEffect
        if (d_effect)
            d_effect->performPreRenderFunctions(pass);

        // draw the batches
        size_t pos = 0;
        BatchList::const_iterator i = d_batches.begin();
        for ( ; i != d_batches.end(); ++i)
        {
            d_material.setTexture(0, (*i).first);
            d_driver.setMaterial(d_material);
            d_driver.drawIndexedTriangleList(&d_vertices[pos], (*i).second,
                                            &d_indices[pos], (*i).second / 3);
            pos += (*i).second;
        }
    }

    // clean up RenderEffect
    if (d_effect)
        d_effect->performPostRenderFunctions();

    // restore original projection matrix and viewport.
    d_driver.setTransform(irr::video::ETS_PROJECTION, proj);
    d_driver.setViewPort(target_vp);
}
Example #11
0
// @deprecated in 2.8
void QgsMapToPixel::setXMinimum( double xmin )
{
  xCenter = xmin + mWidth * mMapUnitsPerPixel / 2.0;
  mRotation = 0.0;
  updateMatrix();
}
Example #12
0
// @deprecated in 2.8
void QgsMapToPixel::setYMinimum( double ymin )
{
  yCenter = ymin + mHeight * mMapUnitsPerPixel / 2.0;
  mRotation = 0.0;
  updateMatrix();
}
Example #13
0
void QgsMapToPixel::setMapUnitsPerPixel( double mapUnitsPerPixel )
{
  mMapUnitsPerPixel = mapUnitsPerPixel;
  updateMatrix();
}
Example #14
0
QgsMapToPixel::QgsMapToPixel()
{
  updateMatrix();
}
Example #15
0
//----------------------------------------------------------------------------//
void OgreGeometryBuffer::draw() const
{
    if (d_vertexData.empty())
        return;

    if (d_dataAppended)
        syncVertexData();

    if (d_hwBuffer.isNull())
        return;

    // setup clip region
    if (d_clippingActive)
    {
        setScissorRects();
    }

    // Update the matrix
    updateMatrix();

    CEGUI::ShaderParameterBindings* shaderParameterBindings = 
        (*d_renderMaterial).getShaderParamBindings();

    // Set the ModelViewProjection matrix in the bindings
    shaderParameterBindings->setParameter("modelViewProjMatrix", d_matrix);


    if (d_alpha != d_previousAlphaValue)
    {
        d_previousAlphaValue = d_alpha;

        shaderParameterBindings->setParameter("alphaPercentage", 
            d_previousAlphaValue);
    }

    // activate the desired blending mode
    d_owner.bindBlendMode(d_blendMode);

    const int pass_count = d_effect ? d_effect->getPassCount() : 1;
    for (int pass = 0; pass < pass_count; ++pass)
    {
        // set up RenderEffect
        if (d_effect)
            d_effect->performPreRenderFunctions(pass);

        //Prepare for the rendering process according to the used render material
        d_renderMaterial->prepareForRendering();

        // draw the geometry
        d_renderSystem._render(d_renderOp);
    }

    // clean up RenderEffect
    if (d_effect)
        d_effect->performPostRenderFunctions();

    // Disable clipping after rendering
    if (d_clippingActive)
    {
        d_renderSystem.setScissorTest(false);
    }

    updateRenderTargetData(d_owner.getActiveRenderTarget());
}