Example #1
0
void VRMLBodyLoaderImpl::readDeviceNode(LinkInfo& iLink, VRMLProtoInstance* deviceNode, const Affine3& T)
{
    const string& typeName = deviceNode->proto->protoName;
    if(isVerbose) putMessage(typeName + " node " + deviceNode->defName);
    
    DeviceFactoryMap::iterator p = deviceFactories.find(typeName);
    if(p == deviceFactories.end()){
        os() << str(format("Sensor type %1% is not supported.\n") % typeName) << endl;
    } else {
        DeviceFactory& factory = p->second;
        DevicePtr device = factory(deviceNode);
        if(device){
            device->setLink(iLink.link);
            const Matrix3 RsT = iLink.link->Rs();
            device->setLocalTranslation(RsT * (T * device->localTranslation()));
            device->setLocalRotation(RsT * (T.linear() * device->localRotation()));
            body->addDevice(device);
        }
    }
}
void ColladaBodyLoaderImpl::setSensor(DaeNode* extNode, Link* link, Body& body)
{
    DaeLink* nodeLink = static_cast<DaeLink*>(extNode);

    DaeResultSensors* sensors = parser->findSensor(nodeLink->id);
    if (sensors->size() <= 0) {
        return;
    }

    // ForceSensor--------->force6d
    // GyroSensor---------->no type(empty string)
    // AccelerrationSensor->imu(unit sensor)
    // VisionSensor-------->pin-hole-camera
       
    for (DaeResultSensors::iterator iters = sensors->begin(); iters != sensors->end(); iters++) {
        DaeSensor* sensor = *iters;
        DevicePtr device = createSensor(sensor);
        device->setLink(link);
        device->setLocalTranslation(extNode->transform.translate + sensor->transform.translate);
        device->setLocalRotation   (extNode->transform.rotate.matrix() * sensor->transform.rotate.matrix());
        body.addDevice(device); 
    } 

}