Beispiel #1
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;
    }
}
Beispiel #2
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");
}
Beispiel #3
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");
}
Beispiel #4
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;
        }

    }

}