Пример #1
0
shared_ptr <GLTF::JSONObject> serializeEffect(GLTFEffect* effect, void *context)
{
    shared_ptr <GLTF::JSONObject> effectObject(new GLTF::JSONObject());
    shared_ptr <GLTF::JSONObject> instanceTechnique(new GLTF::JSONObject());
    shared_ptr <JSONObject> techniqueGenerator = effect->getTechniqueGenerator();

    GLTF::GLTFConverterContext *converterContext= (GLTF::GLTFConverterContext*)context;

    std::string techniqueID = GLTF::getReferenceTechniqueID(techniqueGenerator, *converterContext);

    effectObject->setString("name", effect->getName());
    effectObject->setValue("instanceTechnique", instanceTechnique);
    instanceTechnique->setString("technique", techniqueID);
    shared_ptr<JSONObject> outputs(new JSONObject());
    shared_ptr <JSONObject> values = effect->getValues();
    std::vector <std::string> keys = values->getAllKeys();
    for (size_t i = 0 ; i < keys.size() ; i++) {
        shared_ptr <JSONObject> parameter = static_pointer_cast <JSONObject> (values->getValue(keys[i]));
        shared_ptr <JSONObject> parameterValue = static_pointer_cast <JSONObject> (parameter->getValue("value"));
        shared_ptr<JSONObject> output(new JSONObject());
        if (parameterValue) {
            outputs->setValue(keys[i], parameterValue);
        }
    }
    instanceTechnique->setValue("values", outputs);

    return effectObject;
}
Пример #2
0
    shared_ptr <GLTF::JSONObject> serializeEffect(GLTFEffect* effect, void *context)
    {
        shared_ptr <GLTF::JSONObject> effectObject(new GLTF::JSONObject());
        
        shared_ptr <GLTF::JSONObject> instanceTechnique(new GLTF::JSONObject());
        
        std::string techniqueID = effect->getTechniqueID();

        effectObject->setString("name", effect->getName());
        effectObject->setValue("instanceTechnique", instanceTechnique);
        instanceTechnique->setString("technique", techniqueID);
        shared_ptr<JSONArray> outputs(new JSONArray());
        shared_ptr <JSONObject> values = effect->getValues();
        std::vector <std::string> keys = values->getAllKeys();
        for (size_t i = 0 ; i < keys.size() ; i++) {
            shared_ptr <JSONObject> parameter = static_pointer_cast <JSONObject> (values->getValue(keys[i]));
            shared_ptr <JSONObject> parameterValue = static_pointer_cast <JSONObject> (parameter->getValue("value"));
            shared_ptr<JSONObject> output(new JSONObject());
            if (parameterValue) {
                output->setValue("value", parameterValue);
                output->setString("parameter", keys[i]);
                outputs->appendValue(output);
            }
        }
        instanceTechnique->setValue("values", outputs);
    
        return effectObject;
    }
Пример #3
0
 void GLTFEffect::evaluate(void *context) {
     GLTFAsset* asset = (GLTFAsset*)context;
     shared_ptr <GLTF::JSONObject> instanceTechnique(new GLTF::JSONObject());
     shared_ptr <JSONObject> techniqueGenerator = this->getTechniqueGenerator();
             
     std::string techniqueID = GLTF::getReferenceTechniqueID(techniqueGenerator, asset);
     
     this->setValue(kInstanceTechnique, instanceTechnique);
     instanceTechnique->setString(kTechnique, techniqueID);
     shared_ptr<JSONObject> outputs(new JSONObject());
     shared_ptr <JSONObject> values = this->getValues();
     std::vector <std::string> keys = values->getAllKeys();
     for (size_t i = 0 ; i < keys.size() ; i++) {
         shared_ptr <JSONObject> parameter = static_pointer_cast <JSONObject> (values->getValue(keys[i]));
         shared_ptr <JSONObject> parameterValue = static_pointer_cast <JSONObject> (parameter->getValue(kValue));
         shared_ptr<JSONObject> output(new JSONObject());
         if (parameterValue) {
             outputs->setValue(keys[i], parameterValue);
         }
     }
     instanceTechnique->setValue(kValues, outputs);
 }