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; } } }
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); } }
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"); }
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"); }
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; } } }
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); } }