Пример #1
0
void RResource::setProperties(RPropertyMap const & attr, std::string const & name)
{
    if (name.compare("resource") == 0) {
    } else if (name.compare("shape") == 0) {
        if (attr.has("id")) {
            int id = attr.getInt("id");
            RShape * s = RShapeItem::fromProperty(attr);
            if (s) {
                if (attr.getInt("buffer")) {
                    s->createBuffer();
                }
                if (!mShapes.insert(std::make_pair(id, s)).second) {
                    rLogW() << "insertion of " << name << "(" << id << ") failed" << std::endl;
                }
            }
        }
    } else if(name.compare("texture") == 0) {
        if (attr.has("id")) {
            int id = attr.getInt("id");
            RTexture t = RTextureItem::fromProperty(attr);
            if (!mTextures.insert(std::make_pair(id, t)).second) {
                rLogW() << "insertion of " << name << "(" << id << ") failed" << std::endl;
            }
        }
    } else {
        RResourceItem * item =  getItem(name);
        if (item) {
            item->setProperties(attr, name);
        } else {
            rLogW() << "Resource " << name << " not found" << std::endl;
        }
    }
}
Пример #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;
    }
}
Пример #3
0
void RCPCollision::setProperties(RPropertyMap const & map, std::string const & element)
{
    mTypeA = map.getInt("typeA");
    mTypeB = map.getInt("typeB");

    mBeginFunctionName = map.getString("begin");
    mPreSolveFunctionName = map.getString("presolve");
    mPostSolveFunctionName = map.getString("postsolve");
    mSeparateFunctionName = map.getString("separate");
}
Пример #4
0
void RGCSettings::setProperties(RPropertyMap const & map, std::string const & element)
{
    if (element.compare("depthtest") == 0) {
        mDepthTest = map.getInt("enable", -1);
    } else if (element.compare("blending") == 0) {
        mBlending = map.getInt("enable", -1);
    } else if (element.compare("culling") == 0) {
        mCulling = map.getInt("enable", -1);
    }
}
Пример #5
0
void RSpriteItem::setProperties(RPropertyMap const & map, std::string const & element)
{
    RUIItem::setProperties(map, element);

    int flip = map.getInt("flip");

    setImage(map.getString("image"));

    set(mX, mY, mWidth, mHeight, flip);

    mClickListnerName = map.getString("onclick");
}
Пример #6
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;
        }

    }

}
Пример #7
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()));
}
Пример #8
0
void RFrustumItem::setProperties(RPropertyMap const & map, std::string const & element)
{
    
    if (element.compare("parallel") == 0) {
        mFrustum.parallel(map.getFloat("left"),
                          map.getFloat("right"),
                          map.getFloat("bottom"),
                          map.getFloat("top"),
                          map.getFloat("near"),
                          map.getFloat("far"));
    } else if (element.compare("perspective") == 0) {
        mFrustum.perspective(map.getFloat("left"),
                             map.getFloat("right"),
                             map.getFloat("bottom"),
                             map.getFloat("top"),
                             map.getFloat("near"),
                             map.getFloat("far"));
    } else if (element.compare("perspectivetheta") == 0) {
        mFrustum.perspectiveTheta(map.getFloat("fovy"),
                                  map.getFloat("aspect"),
                                  map.getFloat("near"),
                                  map.getFloat("far"));
    }
}
Пример #9
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);
    }
}