Example #1
0
void RLightItem::setProperties(RPropertyMap const & map, std::string const & element)
{
    mLight.setAmbient(map.getVector("ambient", mLight.ambient()));
    mLight.setDiffuse(map.getVector("diffuse", mLight.diffuse()));
    mLight.setSpecular(map.getVector("specular", mLight.specular()));
    mLight.setPosition(map.getVector("position", mLight.position()));
    mLight.setDirection(map.getVector("direction", mLight.direction()));
    mLight.setSpotExponent(map.getFloat("exponent", mLight.spotExponent()));
    mLight.setSpotCutoff(map.getFloat("cutoff", mLight.spotCutoff()));
    mLight.setConstAttenuation(map.getFloat("constatten", mLight.constAttenuation()));
    mLight.setLinearAttenuation(map.getFloat("linearatten", mLight.linearAttenuation()));
    mLight.setQuadAttenuation(map.getFloat("quadatten", mLight.quadAttenuation()));
}
Example #2
0
void RBulletWorld::setProperties(RPropertyMap const & map, std::string const & name)
{
    destroy();

    if (name.compare("bulletworld") == 0) {
        std::string world = map.getString("world", std::string());
        if (world.compare("collision") == 0) {
            mWorldType = CollisionWorld;
        } else if (world.compare("dynamics") == 0) {
            mWorldType = DynamicsWorld;
        } else if (world.compare("discretedynamics") == 0) {
            mWorldType = DiscreteDynamicsWorld;
        } else if (world.compare("softrigiddynamics") == 0) {
            mWorldType = SoftRigidDynamicsWorld;
        }

        std::string bp = map.getString("broadphase", std::string());
        if (bp.compare("dbvt") == 0) {
            mBroadphaseType = Dbvt;
        } else if (bp.compare("axissweep3") == 0) {
            mBroadphaseType = AxisSweep3;
        } else if (bp.compare("simple") == 0) {
            mBroadphaseType = Simple;
        }

        setGravity(map.getVector("gravity", gravity()));

        create();

        RBulletWorld::mInstance = this;
    }
}
Example #3
0
void RItem::setProperties(RPropertyMap const & map, std::string const & element)
{
    int withEvent = map.getInt("event");
    if (withEvent) {
        RScene::currentScene()->registerEvent(this);
    }

    mCustomMsg = map.getString("custommsg");

    RVector rect = map.getVector("boundedrect");
    mX = rect.x();
    mY = rect.y();
    mWidth = rect.z();
    mHeight = rect.w();

    std::string align = map.getString("align");
    if (align.compare("center") == 0) {
        RItem *p = parent();

        float px = 0.0f;
        float py = 0.0f;
        float pw = 0.0f;
        float ph = 0.0f;

        if (p) {
            px = p->mX;
            py = p->mY;
            pw = p->mWidth;
            ph = p->mHeight;
        }

        if (pw < Epsilon || ph < Epsilon) {
            RScene *s = scene();
            if (s) {
                pw = s->view()->getWidth();
                ph = s->view()->getHeight();
            }
        }

        if (pw > Epsilon && ph > Epsilon) {
            mX = px + (pw - mWidth) / 2.0f;
            mY = py + (ph - mHeight) / 2.0f;
        }

    }

}
Example #4
0
void RParticleItem::setProperties(RPropertyMap const & map, std::string const & element)
{
    if (element.compare("velocityparticles") == 0) {
        RVelocityParticles * ps = new RVelocityParticles();

        RVector sp = map.getVector("speed", RVector(ps->speedFrom(), ps->speedTo()));
        ps->setSpeed(sp.x(), sp.y());

        RVector xv = map.getVector("xvelocity", RVector(ps->xVelocityFrom(), ps->xVelocityTo()));
        ps->setXVelocity(xv.x(), xv.y());
        RVector yv = map.getVector("yvelocity", RVector(ps->yVelocityFrom(), ps->yVelocityTo()));
        ps->setYVelocity(yv.x(), yv.y());
        RVector zv = map.getVector("zvelocity", RVector(ps->zVelocityFrom(), ps->zVelocityTo()));
        ps->setZVelocity(zv.x(), zv.y());

        ps->setMaxX(map.getFloat("maxx", ps->maxX()));
        ps->setMaxY(map.getFloat("maxy", ps->maxY()));
        ps->setMaxZ(map.getFloat("maxz", ps->maxZ()));

        ps->setAlphaTransition(map.getInt("alphatransition", ps->alphaTransition()));

        ps->setGravity(map.getVector("gravity", ps->gravity()));

        mParticles = ps;
    } else if (element.compare("linearparticles") == 0) {
        RLinearParticles * ps = new RLinearParticles();

        RVector xv = map.getVector("xend", RVector(ps->xEndFrom(), ps->xEndTo()));
        ps->setXEnd(xv.x(), xv.y());
        RVector yv = map.getVector("yend", RVector(ps->yEndFrom(), ps->yEndTo()));
        ps->setYEnd(yv.x(), yv.y());
        RVector zv = map.getVector("zend", RVector(ps->zEndFrom(), ps->zEndTo()));
        ps->setZEnd(zv.x(), zv.y());

        mParticles = ps;
    } else if (element.compare("bezierparticles") == 0) {
        RBezierParticles * ps = new RBezierParticles();

        RVector xv = map.getVector("xend", RVector(ps->xEndFrom(), ps->xEndTo()));
        ps->setXEnd(xv.x(), xv.y());
        RVector yv = map.getVector("yend", RVector(ps->yEndFrom(), ps->yEndTo()));
        ps->setYEnd(yv.x(), yv.y());
        RVector zv = map.getVector("zend", RVector(ps->zEndFrom(), ps->zEndTo()));
        ps->setZEnd(zv.x(), zv.y());

        xv = map.getVector("xcontrol", RVector(ps->xControlFrom(), ps->xControlTo()));
        ps->setXControl(xv.x(), xv.y());
        yv = map.getVector("ycontrol", RVector(ps->yControlFrom(), ps->yControlTo()));
        ps->setYControl(yv.x(), yv.y());
        zv = map.getVector("zcontrol", RVector(ps->zControlFrom(), ps->zControlTo()));
        ps->setZControl(zv.x(), zv.y());

        mParticles = ps;
    }

    if (!mParticles.isNull()) {
        RVector xv = map.getVector("xstart", RVector(mParticles->xStartFrom(), mParticles->xStartTo()));
        mParticles->setXStart(xv.x(), xv.y());
        RVector yv = map.getVector("ystart", RVector(mParticles->yStartFrom(), mParticles->yStartTo()));
        mParticles->setYStart(yv.x(), yv.y());
        RVector zv = map.getVector("zstart", RVector(mParticles->zStartFrom(), mParticles->zStartTo()));
        mParticles->setZStart(zv.x(), zv.y());

        mParticles->setMaximumParticleCount(map.getInt("count", mParticles->count())); 

        mParticles->setSize(map.getInt("size", mParticles->size())); 
        mParticles->setSmoothStop(map.getInt("smoothstop", mParticles->smoothStop())); 

        RAnimationItem::setProperties(map, element);
    }
}