Esempio n. 1
0
 void PropertyGridBTModelAdapter::buildProperties()
 {
     // model debug flag
     {
         PropertyGridProperty *prop = new PropertyGridProperty("Debug");
         PropertyGridProperty::BoolReadCallback readCB([this]()->bool
         {
             BTModel *const btModel = mLevel->BTModelMan()->at(mMid);
             return btModel->debug();
         });
         PropertyGridProperty::BoolWriteCallback writeCB([this](bool flag)
         {
             BTModel *const btModel = mLevel->BTModelMan()->at(mMid);
             return btModel->setDebug(flag);
         });
         prop->setCallbacks(readCB, writeCB);
         PropertyGridAdapter::mProperties.push_back(prop);
     }
     // stateStream name
     {
         PropertyGridProperty *prop = new PropertyGridProperty("StateStream");
         PropertyGridProperty::StringReadCallback readCB([this]()->Ogre::String
         {
             BTModel *const btModel = mLevel->BTModelMan()->at(mMid);
             return btModel->stateStream().debugName();
         });
         prop->setCallbacks(readCB, nullptr);
         PropertyGridAdapter::mProperties.push_back(prop);
     }
 }
Esempio n. 2
0
    void PropertyGridAgentAdapter::buildProperties()
    {
        Agent *agent = mAgentMan->getAgent(mAid);

        if(nullptr == agent)
        {
            PropertyGridProperty *prop_id = new PropertyGridProperty("AgentId " + Ogre::StringConverter::toString(mAid) + " (invalid)");
            mProperties.push_back(prop_id);
            Debug::error(STEEL_METH_INTRO, "could not find agent ", mAid).endl();
            return;
        }

        /// gaent name
        {
            PropertyGridProperty *prop = new PropertyGridProperty("Name");
            PropertyGridProperty::StringReadCallback readCB([this]()->Ogre::String
            {
                Agent *agent = mAgentMan->getAgent(mAid);
                return agent->name();
            });
            PropertyGridProperty::StringWriteCallback writeCB([this](Ogre::String const& name)
            {
                Agent *agent = mAgentMan->getAgent(mAid);
                agent->setName(name);
            });
            prop->setCallbacks(readCB, writeCB);
            mProperties.push_back(prop);
        }

        /// persistence toggle
        {
            PropertyGridProperty *prop = new PropertyGridProperty("Persistent");
            PropertyGridProperty::BoolReadCallback readCB([this]()->bool
            {
                Agent *agent = mAgentMan->getAgent(mAid);
                return agent->isPersistent();
            });
            PropertyGridProperty::BoolWriteCallback writeCB([this](bool flag)
            {
                Agent *agent = mAgentMan->getAgent(mAid);
                agent->setPersistent(flag);
            });
            prop->setCallbacks(readCB, writeCB);
            mProperties.push_back(prop);
        }
    }
Esempio n. 3
0
    void PropertyGridPhysicsModelAdapter::buildProperties()
    {
        // speed
        {
            PropertyGridProperty *prop = new PropertyGridProperty("Velocity");
            PropertyGridProperty::StringReadCallback readCB([this]()->Ogre::String
            {
                PhysicsModel *const pmodel = mLevel->physicsModelMan()->at(mMid);

                if(nullptr == pmodel)
                    return StringUtils::BLANK;

                Ogre::Vector3 const v = pmodel->velocity();
                u16 width = 4;
                Ogre::String const r = "{" +
                Ogre::StringConverter::toString(v.x, width) + ", " +
                Ogre::StringConverter::toString(v.y, width) + ", " +
                Ogre::StringConverter::toString(v.z, width)
                + "}";
                return r;
            });
            prop->setCallbacks(readCB, nullptr);
            PropertyGridAdapter::mProperties.push_back(prop);
        }

        // shape list
        {
            PropertyGridProperty *prop = new PropertyGridProperty(PhysicsModel::BBOX_SHAPE_ATTRIBUTE);
            PropertyGridProperty::StringVectorSelectionReadCallback readCB([this]()->PropertyGridProperty::StringVectorSelection
            {
                PropertyGridProperty::StringVectorSelection readItem;
                PhysicsModel *const pmodel = mLevel->physicsModelMan()->at(mMid);

                if(nullptr == pmodel)
                    return readItem;

                readItem.selectableValues = boundingShapeValues();
                readItem.selectedIndex = (PropertyGridProperty::StringVectorSelection::selection_type)(std::find(readItem.selectableValues.begin(), readItem.selectableValues.end(), toString(pmodel->shape())) - readItem.selectableValues.begin());

                return readItem;
            });
            PropertyGridProperty::StringVectorSelectionWriteCallback writeCB([this](PropertyGridProperty::StringVectorSelection::selection_type index)
            {
                Agent *const agent = mLevel->agentMan()->getAgent(mAid);

                if(nullptr == agent)
                    return;

                OgreModel *const omodel = agent->ogreModel();
                PhysicsModel *const pmodel = mLevel->physicsModelMan()->at(mMid);

                if(nullptr == omodel || nullptr == pmodel)
                    return;

                StringVector possibleValues = boundingShapeValues();
                BoundingShape shape = BoundingShape::SPHERE;

                if(index < possibleValues.size())
                    shape = toBoundingShape(possibleValues[index]);

                pmodel->setShape(omodel, shape);
            });
            prop->setCallbacks(readCB, writeCB);
            PropertyGridAdapter::mProperties.push_back(prop);
        }

        // mass
        {
            PropertyGridProperty *prop = new PropertyGridProperty(PhysicsModel::MASS_ATTRIBUTE);
            PropertyGridProperty::RangeReadCallback readCB([this]()->PropertyGridProperty::Range
            {
                PropertyGridProperty::Range range;
                PhysicsModel *const pmodel = mLevel->physicsModelMan()->at(mMid);

                if(nullptr != pmodel)
                    range.value = (PropertyGridProperty::Range::value_type)pmodel->mass();

                range.min = 0.;
                range.max = 100.;
                Numeric::clamp(range.value, range.min, range.max);
                return range;
            });
            PropertyGridProperty::RangeWriteCallback writeCB([this](PropertyGridProperty::Range const & range)
            {
                PhysicsModel *const pmodel = mLevel->physicsModelMan()->at(mMid);
                Numeric::clamp(range.value, range.min, range.max);
                pmodel->setMass((decltype(pmodel->mass()))range.value);
            });
            prop->setCallbacks(readCB, writeCB);
            PropertyGridAdapter::mProperties.push_back(prop);
        }

        // damping
        {
            PropertyGridProperty *prop = new PropertyGridProperty(PhysicsModel::DAMPING_ATTRIBUTE);
            PropertyGridProperty::RangeReadCallback readCB([this]()->PropertyGridProperty::Range
            {
                PropertyGridProperty::Range range;
                PhysicsModel *const pmodel = mLevel->physicsModelMan()->at(mMid);

                if(nullptr != pmodel)
                    range.value = (PropertyGridProperty::Range::value_type)pmodel->linearDamping();

                range.min = 0.;
                range.max = 1.;
                Numeric::clamp(range.value, range.min, range.max);
                return range;
            });
            PropertyGridProperty::RangeWriteCallback writeCB([this](PropertyGridProperty::Range const & range)
            {
                PhysicsModel *const pmodel = mLevel->physicsModelMan()->at(mMid);
                Numeric::clamp(range.value, range.min, range.max);
                pmodel->setDamping((decltype(pmodel->mass()))range.value);
            });
            prop->setCallbacks(readCB, writeCB);
            PropertyGridAdapter::mProperties.push_back(prop);
        }

        PhysicsModel *const pmodel = mLevel->physicsModelMan()->at(mMid);

        if(nullptr != pmodel)
            registerSignal(pmodel->getSignal(PhysicsModel::PublicSignal::transformed));
    }
Esempio n. 4
0
int32_t ABLFile::write(puint8_t buffer, int32_t length)
{
	if (file)
		return (writeCB(file, buffer, length));
	return (0);
}
Esempio n. 5
0
long ABLFile::write (unsigned char* buffer, long length) {

	if (file)
		return(writeCB(file, buffer, length));
	return(0);
}