Ejemplo n.º 1
0
    public void setChangedParameterIntoHost(int id)
    {
        if (prControl == null)
        {
            return;
        }
        if (prControl.prAsset == null)
        {
            return;
        }

        if (id == -1)
        {
            return;
        }

        HAPI_ParmInfo parm = findParm(id);

        if ((HAPI_ParmType)parm.type == HAPI_ParmType.HAPI_PARMTYPE_MULTIPARMLIST)
        {
            int[] values = new int[1];
            HoudiniHost.getParmIntValues(prControl.prNodeId, values, parm.intValuesIndex, 1);

            int difference = prParmIntValues[parm.intValuesIndex] - values[0];
            if (difference > 0)
            {
                appendMultiparmInstances(parm, difference);
            }
            else if (difference < 0)
            {
                removeMultiparmInstances(parm, -difference);
            }

            getParameterValues();
        }
        else if (parm.isNode())
        {
            setChangedNodeParameterIntoHost(id);
        }
        else if (parm.isFloat())
        {
            float[] values = new float[parm.size];
            Array.Copy(prParmFloatValues, parm.floatValuesIndex, values, 0, parm.size);
            HoudiniHost.setParmFloatValues(prControl.prNodeId, values, parm.floatValuesIndex, parm.size);
        }
        else if (parm.isInt() && (HAPI_ParmType)parm.type != HAPI_ParmType.HAPI_PARMTYPE_MULTIPARMLIST)
        {
            int[] values = new int[parm.size];
            Array.Copy(prParmIntValues, parm.intValuesIndex, values, 0, parm.size);
            HoudiniHost.setParmIntValues(prControl.prNodeId, values, parm.intValuesIndex, parm.size);
        }
        else if (parm.isString())
        {
            string[] strings = getParmStrings(parm);
            for (int p = 0; p < parm.size; ++p)
            {
                HoudiniHost.setParmStringValue(prControl.prNodeId, strings[p], parm.id, p);
            }
        }
    }
    public float getParmFloatValue(string name, int index)
    {
        HAPI_ParmInfo parm_info = myAssetParms.findParm(name);

        if (parm_info.isFloat())
        {
            return(myAssetParms.prParmFloatValues[parm_info.floatValuesIndex + index]);
        }

        throw new HoudiniErrorInvalidArgument(name + " is not a float!");
    }
    public void setParmFloatValue(string name, int index, float value)
    {
        HAPI_ParmInfo parm_info = myAssetParms.findParm(name);

        if (!parm_info.isFloat())
        {
            throw new HoudiniErrorInvalidArgument(name + " is not a float!");
        }

        int values_index = parm_info.floatValuesIndex + index;

        float[] float_value = { value };

        HoudiniHost.setParmFloatValues(myAsset.prNodeId, float_value, values_index, 1);

        myAsset.buildClientSide();
    }
    public ParmType getParmType(string name)
    {
        HAPI_ParmInfo parm_info = myAssetParms.findParm(name);

        if (parm_info.isInt())
        {
            return(ParmType.INT);
        }
        if (parm_info.isFloat())
        {
            return(ParmType.FLOAT);
        }
        if (parm_info.isString())
        {
            return(ParmType.STRING);
        }
        if (parm_info.isNonValue())
        {
            return(ParmType.IMMUTABLE);
        }

        return(ParmType.INVALID);
    }
    // Checks if the parameter with the given id parm_id represents the same parameter
    // with the same value in this set of parameters and another set of parameters parmsB.
    public bool isParmSameInPrefab(int parm_id, HoudiniParms parmsB)
    {
        HAPI_ParmInfo parm_infoA = findParm(parm_id);
        HAPI_ParmInfo parm_infoB = parmsB.findParm(parm_id);

        if (parm_infoA.GetType() != parm_infoB.GetType() ||
            parm_infoA.size != parm_infoB.size ||
            parm_infoA.name != parm_infoB.name ||
            parm_infoA.label != parm_infoB.label)
        {
            Debug.LogError("Parameter structure is different from prefab");
            return(false);
        }

        // only need to check type and size of one because already checked that
        // parameter infos have  type and size
        if (parm_infoA.isFloat())
        {
            for (int ii = 0; ii < parm_infoA.size; ii++)
            {
                float valueA = prParmFloatValues[parm_infoA.floatValuesIndex + ii];
                float valueB = parmsB.prParmFloatValues[parm_infoB.floatValuesIndex + ii];
                if (valueA != valueB)
                {
                    return(false);
                }
            }
        }
        else if (parm_infoB.isInt())
        {
            for (int ii = 0; ii < parm_infoA.size; ii++)
            {
                int valueA = prParmIntValues[parm_infoA.intValuesIndex + ii];
                int valueB = parmsB.prParmIntValues[parm_infoB.intValuesIndex + ii];
                if (valueA != valueB)
                {
                    return(false);
                }
            }
        }
        else if (parm_infoB.isString())
        {
            string[] valuesA = getParmStrings(parm_infoA);
            string[] valuesB = parmsB.getParmStrings(parm_infoB);

            if (valuesA.Length != valuesB.Length)
            {
                return(false);
            }

            for (int ii = 0; ii < valuesA.Length; ii++)
            {
                if (valuesA[ii] != valuesB[ii])
                {
                    return(false);
                }
            }
        }

        return(true);
    }